clang enum overflow
问题 Using -Wall -pedantic #include <limits.h> #include <stdio.h> int main(void) { enum x { a, max = INT_MAX, out_1 }; enum y { b, out_2 = INT_MAX + 1 }; printf("%d %d\n", out_1, out_2); return 0; } clang returns demo.c:9:3: warning: overflow in enumeration value out_1 ^ As you can see, compiler does not warn about out_2 overflow, his value is unknown at compile time? 回答1: In the first instance, the compiler itself is trying to pick an integer that is causing an overflow, and so is warning you. It