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

            Bug ID: 115684
           Summary: No warning for pointer and enum field comparison
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Hi-Angel at yandex dot ru
  Target Milestone: ---

Comparing an enum field with a pointer produces no warnings (while comparing an
int to a pointer produces them). We just had a regression due to this missing
check, such code clearly shouldn't have been compiled in the first place (well,
with Wfatal of course).

# Steps to reproduce (in terms of terminal commands)

    λ cat test.c
    #include <stdio.h>

    int main() {
        enum { myEnumField };
        int a = 0;
        int *b = &a;
        if (b == myEnumField)
            puts("hey");
    }
    λ gcc test.c -o a -g3 -O0 -Wall -Wextra -Wsign-conversion


## Expected

A warning, something like:

    test.c:16:11: warning: comparison between pointer and enum field
       16 |     if (b == myEnumField)


## Actual

No warnings being produced

Reply via email to