[Bug c/92668] New: -Wtautological-compare warns for macros that expand to the same symbol

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Nov 25 22:25:00 GMT 2019


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

            Bug ID: 92668
           Summary: -Wtautological-compare warns for macros that expand to
                    the same symbol
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

Unlike the C++ front-end and unlike Clang, the C front-end issues
-Wtautological-compare for comparisons involving distinct macros that expand to
the same symbol.  GCC should be consistent with itself, and what Clang does
seems reasonable, so probably also with it.

$ cat t.c && gcc -S -Wall -Wextra -Wtautological-compare t.c
int a;

#define X a
#define Y a

int f (void)
{
  if (X == Y) return 1;
  return 0;
}
t.c: In function ‘f’:
t.c:8:9: warning: self-comparison always evaluates to true
[-Wtautological-compare]
    8 |   if (X == Y) return 1;
      |         ^~


More information about the Gcc-bugs mailing list