$ cat enum-test.c
enum foo_enum { FOO };
int
main (void)
{
enum foo_enum foo;
if (foo >= FOO)
{
}
}
$ gcc -Wextra enum-test.c
enum-test.c: In function 'main':
enum-test.c:7: warning: comparison of unsigned expression >= 0 is always true
I looked through existing bug reports but didn't find this. If it's a dupe,
please let me know what I should have searched for.
Here is an old thread I found about a related test-case:
http://gcc.gnu.org/ml/gcc-patches/2000-07/msg00772.html
I'm not sure, but even if it's only C99 that says enums have to be ints, the
promotion shouldn't happen for C89 either.
--
Summary: enum int type gets promoted to unsigned int in
comparison
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: chris dot pickett at mail dot mcgill dot ca
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29774