[cfe-dev] Warnings: -w options and default
Douglas Gregor
dgregor at apple.com
Mon Sep 13 08:42:49 PDT 2010
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
More information about the cfe-dev
mailing list