https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107405
Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jsm28 at gcc dot gnu.org Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2022-10-26 --- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> --- > enum { A = 0xffffffff, B = 1 << 31, }; > int main() { printf("%lx %x %zu\n", A, B, sizeof(B)); } > Apparently, 0xffffffff is treated by the compiler as unsigned int constant and thus it likely leads to the promotion to a longer interger. Joseph will explain better. If you use -1, it's fine: enum { A = -1, B = 1 << 31, }; int main() { printf("%x %x %zu\n", A, B, sizeof(B)); } $ gcc pr107405.c -Wall && ./a.out ffffffff 80000000 4