Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-11-16 20:02:49


"Stephan T. Lavavej" <stl_at_[hidden]> writes:

> [David Abrahams]
>> Be happy to, once you convince the GCC developers to start supporting
>> #pragmas ;-)
>
> Huh? #pragma GCC system_header is supported by GCC; that's why I mentioned
> it. See: http://gcc.gnu.org/onlinedocs/gcc-3.3.2/cpp/Pragmas.html#Pragmas

Ow. That's quite a large hammer.

> [Stephan T. Lavavej]
>> 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
>> -Woverloaded-virtual
>
> [David Abrahams]
>> OK, but what makes your set of warnings the right set?
>
> I mentioned my set of warnings only as an example of one possible
> set. Boost should come to a consensus about what warnings its
> libraries should be compiled with.

My question was to point out that it may be difficult to reach such a
consensus.

> Even if Boost's developers are comfortable with code that uses
> shadowing, using shadowing in Boost forces this decision on all of
> Boost's users, and that isn't nice. It's the Wrath of Khan
> principle: The needs of the many outweigh the needs of the few... or
> the one.

This is my last argument about this; I'll leave it to others to weigh
in and reach a consensus. I'm still not comfortable with -Wshadow:

    -Wshadow

    Warn whenever a local variable shadows another local variable,
    parameter or global variable or whenever a built-in function is
    shadowed.

This leads to "problems" like this one:

    namespace boost // library 1
    {
      extern int foo;
    }

    namespace boost // library 2
    {
      char* bar(int foo) {}
    }

We can't even effectively test for possible shadowing unless we try to
compile all the boost headers into a single translation unit. Maybe
the problem is limited because we don't have many globals; I'm not
sure. I know that Spirit/Phoenix is planning to expand its use of
global function objects. If we accept FC++ it will do that, too.

If trying to avoid -Wshadow reports is too much of a pain for Boost
developers, it will hurt everyone. Maybe it won't be too painful,
though.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk