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

            Bug ID: 83305
           Summary: Some warnings are suppressed when compiling
                    preprocessed files
           Product: gcc
           Version: 7.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rrendec at arista dot com
  Target Milestone: ---

Test sample code:

#include <stdlib.h>
int foo() {
   return 1 != NULL;
}

When compiling directly, this produces the following warning:

$ g++ -c -o test.o test.cpp  
test.cpp: In function ‘int foo()’:
test.cpp:3:16: warning: NULL used in arithmetic [-Wpointer-arith]
    return 1 != NULL;
                ^~~~

When preprocessing and compiling in separate steps, it produces no warnings:
$ g++ -c -E -o test.ii test.cpp
$ g++ -c -o test.o test.ii

The same happens when using -no-integrated-cpp or -save-temps.

The notable use case is ccache, which compiles the preprocessed file as an
optimization.

This looks very similar to BUG60014, but looking at the preprocessor output it
seems this is a different issue. It also looks very similar to BUG60723.

In fact, I believe this is a side effect of the patches that fix BUG60723. With
older gcc versions that don't have the patches (e.g. 4.7.2), the line markers
around __null in the preprocessed output are not present and the problem does
not appear.

Reply via email to