https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57201

--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> ---
PR 60100 seems to be the opposite case, where a warning disappears when
-save-temps is used. Related, but maybe not a dup.

Anyway, here's another example where -save-temps (or preprocessing and
compiling separately) makes a warning disappear, from
https://gcc.gnu.org/ml/gcc-help/2019-05/msg00073.html


#include <stdio.h>
int main()
{
return NULL;
}

g++ -Wconversion-null w.cc
w.cc: In function ‘int main()’:
w.cc:4:8: warning: converting to non-pointer type ‘int’ from NULL
[-Wconversion-null]
 return NULL;
        ^~~~

g++ -Wconversion-null w.cc -save-temps
[no warnings]

g++ -Wconversion-null w.cc -save-temps -Wsystem-headers
w.cc: In function ‘int main()’:
w.cc:4:7: warning: converting to non-pointer type ‘int’ from NULL
[-Wconversion-null]
 return NULL;
       ^~~~~~

g++ -E w.cc -o w.ii && g++ -Wconversion-null w.ii
[no warnings]

g++ -E w.cc -o w.ii && g++ -Wconversion-null w.ii -Wsystem-headers
w.cc: In function ‘int main()’:
w.cc:4:7: warning: converting to non-pointer type ‘int’ from NULL
[-Wconversion-null]
 return NULL;
       ^~~~~~


So by default we warn, but when using -save-temps (or preprocessing and
compiling separately) the warning is suppressed because GCC thinks it's from a
system header.

Our diagnostics related to macros in system headers are so broken.

Reply via email to