Boost logo

Boost :

From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2003-11-16 17:28:48

[David Abrahams]
> I am reluctant to cater to every possible warning. This is an
> example of one which often flags perfectly good code.

But is it really perfectly good code?

Quoth the GCC Manual, "Warnings are diagnostic messages that report
constructions which are not inherently erroneous but which are risky or
suggest there may have been an error."

Code with shadowed variables can be completely correct, but shadowing is
still risky. Thus, I /don't/ think that code which -Wshadow complains about
is perfectly good code.

Unlike some warnings which are difficult to fix, shadowing can always be
avoided easily: simply rename the offending variable. (If it's hard to
figure out what a given name refers to, then that's all the more reason that
the shadowing should be eliminated.) Shadowing adds zero power or
convenience, but does add danger.

> Should we try to come to a concensus about this?

A decision one way or the other would be nice.

If you decide that Boost shouldn't be -Wshadow clean, then at the very least
it would be nice to add a #pragma GCC system_header to each header file when
they're being used by users and not developers. Otherwise, using Boost will
make -Wshadow useless, which is just as bad as, say, polluting the user's

> Should we go the other direction, and simply enable all warnings in our
> Boost.Build toolsets?

The warnings that I compile my own code with are:

-Wall -W -Wfloat-equal -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align
-Wwrite-strings -Wconversion -fno-nonansi-builtins -Wold-style-cast

Stephan T. Lavavej

Boost list run by bdawes at, gregod at, cpdaniel at, john at