[cfe-dev] Warnings difference between gcc and clang

Edward Diener via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 9 16:09:22 PDT 2015


On 10/9/2015 6:28 PM, Richard Smith via cfe-dev wrote:
> On Fri, Oct 9, 2015 at 3:19 PM, Edward Diener via cfe-dev
> <cfe-dev at lists.llvm.org
> <mailto:cfe-dev at lists.llvm.org>> wrote:
>
>     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.




More information about the cfe-dev mailing list