Warnings: -w options and default

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Warnings: -w options and default

Luc Bourhis
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




_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Warnings: -w options and default

Douglas Gregor

On Sep 13, 2010, at 3:20 AM, Luc Bourhis wrote:

> 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
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Warnings: -w options and default

Chris Lattner

On Sep 13, 2010, at 8:42 AM, Douglas Gregor wrote:

>>
>> 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.

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
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Warnings: -w options and default

Luc Bourhis
In reply to this post by Douglas Gregor
> 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




_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

smime.p7s (4K) Download Attachment