https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94142
Bug ID: 94142 Summary: typeof enum member appears to give wrong signedness Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: matthew.fernandez at gmail dot com Target Milestone: --- Consider the following code: typedef enum { A, B } t; t x; __typeof__(A) y; int foo() { if (x == y) return 0; return 1; } With GCC 9.2.0, compiling with -Wsign-compare has the following to say: $ gcc-9.2.0 -std=gnu11 -c -Wsign-compare goo.c foo.c: In function 'foo': foo.c:6:9: warning: comparison of integer expressions of different sightedness: 't' {aka 'enum <anonymous>'} and 'int' [-Wsign-compare] 6 | if (x == y) | ^~ This seems surprising to me. Shouldn't x and y have the same signedness as they're both the type of the enum? It seems like somehow the type of an enum member differs from the type of the enum itself. Either way, the warning seems spurious here. Maybe #66773 is relevant. Some cursory testing suggests to me this behaviour extends back to at least the GCC 4 series. I could not find a version of Clang that has this behaviour.