|
Boost : |
Subject: Re: [boost] Current Guidance on Compiler Warnings?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2018-11-22 01:49:34
On Wed, Nov 21, 2018 at 5:01 PM Edward Diener via Boost <
boost_at_[hidden]> wrote:
> I agree with you that preventing possible errors is a worthwhile goal.
> Where we disagree sharply is the tedious elimination of warnings on
> perfectly correct code as a path to that prevention. It is a huge waste
> of time, and totally unnecessary to boot, to change code to prevent
> warnings when the code is correct in doing what it aims to accomplish.
It's actually worse than that, enforcing warning-free compilation leads to
bugs.
First, any change in a correct program can introduce a new bug. Secondly,
"fixing" a warning often alters the semantics of the operation in a subtle
way. Consider for example the use of an explicit cast to silence a warning
that an implicit conversion may lead to something bad. You may think that
all you've done is silence the warning, but in fact you've changed the
program semantically: it no longer does an implicit type conversion,
instead it does an explicit one. And the thing is, one of the two is
incorrect.
Now, if your programmers don't understand how implicit type conversions
work in C++, it is possible that enforcing warning-free compilation avoids
more bugs than it causes. If that's the case, there's no argument.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk