Warnings: -w options and default

Hi,

am I correct to think that clang ignores the "-w" command line options? I could not find it documented one way or the other (I am talking about the user documentation here). It is pretty annoying for developing code that has to be build by the both of clang and g++.

Moreover, the warning option -Wmismatched-tags is enabled by default, which in my builds triggers reports about conflicting "struct complex" and "class complex" because the standard header declares:

  template<typename _Tp>
    struct complex
    {
    ......

whereas the Boost header <boost/detail/container_fwd.hpp> features

namespace std
{
.......
    template <class T> class complex;
}

May I ask what danger is there in that construct that motivates a warning by default? If I were to push a bug report to the Boost people, I'd better be clad in certainties.

Luc Bourhis
Computer Scientist
Chemical Crystallography Laboratory
University of Durham, UK

Hi,

am I correct to think that clang ignores the "-w" command line options? I could not find it documented one way or the other (I am talking about the user documentation here). It is pretty annoying for developing code that has to be build by the both of clang and g++.

Clang does not ignore the "-w" command-line options. -w turns off warnings, -Wwhatever turns on a category of warnings, -Wno-whatever turns off a category of warnings, etc. It's very similar to GCC.

Moreover, the warning option -Wmismatched-tags is enabled by default,

No, it is not enabled by default. From the source:

def warn_struct_class_tag_mismatch : Warning<
    "%select{struct|class}0 %select{|template}1 %2 was previously declared "
    "as a %select{class|struct}0 %select{|template}1">,
    InGroup<MismatchedTags>, DefaultIgnore;

"DefaultIgnore" means that it is disabled by default. There's probably a -Wall somewhere in your build.

which in my builds triggers reports about conflicting "struct complex" and "class complex" because the standard header declares:

template<typename _Tp>
   struct complex
   {
   ......

whereas the Boost header <boost/detail/container_fwd.hpp> features

namespace std
{
.......
   template <class T> class complex;
}

May I ask what danger is there in that construct that motivates a warning by default? If I were to push a bug report to the Boost people, I'd better be clad in certainties.

IIRC, Visual C++ actually cares about the struct/class difference more than it should (I don't recall the details), so a portable code-base might want this warning. In any case, it isn't important enough to turn on by default, so we didn't.

The bug here is actually in the standard library header, which should be using "class" as specified in the standard. Boost may choose to work around this bug, of course.

  - Doug

It is very dangerous in VC++, it changes the mangling of the type in some cases, so you can get link errors if you mismatch tags.

-Chris

There's probably a -Wall somewhere in your build.

A handfull of objects are indeed built with that flag. Sorry for the confusion.

Thanks,

Luc