Warnings difference between gcc and clang

According to the gcc documentation if -Wall is used on the command line it can be overriddent by individual -Wno-xxx warnings which turn off individual warnings. But in clang if -Wall is used on the command line individual -Wno-xxx warnings are ignored.

I personally favor gcc's approach and would like to see clang treat warnings as gcc does.

That's not true. For clang, warning flags are processed left-to-right, so
-Wno-xxx flags appearing after -Wall turn off individual flags. (The way
clang's warning groups work in general is as if -Wgroup expands to
individual -W flags for each warning in the group; -Wall is just a normal
warning group containing a certain set of warnings.)

Does GCC really allow -Wno-xxx flags that /precede/ -Wall on the command
line to override -Wall? That seems broken.

This is not true. clang is just order sensitive, so put the -Wno-xxx
flags *after* -Wall.

Joerg

    According to the gcc documentation if -Wall is used on the command
    line it can be overriddent by individual -Wno-xxx warnings which
    turn off individual warnings. But in clang if -Wall is used on the
    command line individual -Wno-xxx warnings are ignored.

That's not true. For clang, warning flags are processed left-to-right,
so -Wno-xxx flags appearing after -Wall turn off individual flags. (The
way clang's warning groups work in general is as if -Wgroup expands to
individual -W flags for each warning in the group; -Wall is just a
normal warning group containing a certain set of warnings.)

I stand corrected.

Does GCC really allow -Wno-xxx flags that /precede/ -Wall on the command
line to override -Wall? That seems broken.

Yes, but it is not broken. According to gcc's documentation that is the way it should be. The gcc compiler is not order sensitive in allowing a specific compiler warning to override a general compiler warning. Therefore a specific -Wno-xxx warning will override a -Wall or -Wextra warning no matter where on the command line a specific warning is in relation to the general warning.

I feel that gcc's way of treating warnings on the command line is superior to clang's way of treating warnings on the command line. I do understand that if you have two specific warnings that conflict the last one on the command line should be the one chosen, but I think that any specific warning should be allowed to override any generalized warning.

Just because someone had the brilliant idea to implement it that way
doesn't mean others agree. Most important, the GCC behavior starts to
show its insanity as soon as you have multiple levels of warning groups.

Joerg

pain,
especially when you're not constructing the command line manually, but
rather using
one put together in bits and pieces by a build system. On more than one
occasion I
have cursed at my computer because various (admittedly non-warning) options
have
been the wrong way around on the command line.

I also don't see any insanity with this sort of behavior on multiple levels
of warning groups -
at least from a users' perspective. The options are taken as an unordered
set, and the
most specific version "wins". True, it may get confusing if you don't know
which options are
included with a group, but that's also true for the order dependent version
and constructs like
"-Wno-xxx -Wgroup". If anything, to me the order independent one would seem
less confusing,
as you don't ever get "I explicitly set -Wno-xxx! Why am I getting xxx
warnings?!"

Just my two cents.

From my random outside user's perspective, order dependent options are a
pain,
especially when you're not constructing the command line manually, but
rather using
one put together in bits and pieces by a build system. On more than one
occasion I
have cursed at my computer because various (admittedly non-warning) options
have
been the wrong way around on the command line.

...and the reverse is also true. Options are *naturally* order
dependent. Just consider -Wfoo and -Wno-foo.

I also don't see any insanity with this sort of behavior on multiple levels
of warning groups -
at least from a users' perspective. The options are taken as an unordered
set, and the
most specific version "wins". True, it may get confusing if you don't know
which options are
included with a group, but that's also true for the order dependent version
and constructs like
"-Wno-xxx -Wgroup". If anything, to me the order independent one would seem
less confusing,
as you don't ever get "I explicitly set -Wno-xxx! Why am I getting xxx
warnings?!"

You are forgetting the implictation of having -Wno-group in the mix. So
given a random permution of -Wall, -Wgroup, -Wno-group, -Wmember and
-Wno-member, which one wins? I find a rule that says "right-most wins"
to be much simpler to remember than "-Wall wins, then right most of
-Wgroup / -Wno-group, otherwise right most of -Wmember / -Wno-member".

Joerg