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

            Bug ID: 61280
           Summary: GCC 4.8.2 suppresses -Wsign-compare caused by macro
                    defined in system header
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: java4ada at yahoo dot com

It seems that since 4.8 GCC grants -Wsign-compare immunity to macro defined in
system header.  To reproduce it:

$ cat > test.h <<EOF
#pragma GCC system_header
#define LESS(a, b)  ((a) < (b))
EOF

$ cat > test.c <<EOF
#include "test.h"
int foo(int i, unsigned j) { return LESS(i, j); }
EOF

$ gcc -W -c test.c   # no warning
$ gcc -W -c test.c -save-temps  # system-header bit lost in the preprocessed
file 
test.c: In function 'foo':
test.c:2:42: warning: comparison between signed and unsigned integer
expressions [-Wsign-compare]
 int foo(int i, unsigned j) { return LESS(i, j); }

Prefixing gcc with ccache reproduces the same issue since ccache calls "gcc -E"
and uses preprocessed file (among other things) to compute key, and passes the
preprocessed file to cc1 for compilation when cache miss.

Wondering if this is a new features in gcc4.8 or a bug.

Reply via email to