https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115684
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |egallager at gcc dot gnu.org
--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
I modified it slightly and got it it to warn:
$ cat 115684.c
#include <stdio.h>
int main(void) {
enum { myEnumField0, myEnumField1 };
int a = 0;
int *b = &a;
if (b == myEnumField0)
return puts("hey");
else if (b == myEnumField1)
return puts("yeh");
return a;
}
$ /usr/local/bin/gcc -c -g3 -O3 -Wall -Wextra -Wconversion -pedantic
-Wc++-compat -Wunused 115684.c
115684.c: In function 'main':
115684.c:9:16: warning: comparison between pointer and integer
9 | else if (b == myEnumField1)
| ^~
$
So, it depends on the value of the enumerator, it seems. Also it's a problem
that the existing warning doesn't seem to be linked to a flag; see bug 44209