Does i++ invoke undefined behavior for signed types smaller than int in case of overflow?
问题 It seems clear that the following code invokes undefined behavior because of arithmetic overflow: #include <limits.h> int test(void) { int i = INT_MAX; i++; /* undefined behavior */ return i; } But what about signed types smaller than int such as short or signed char ? (by smaller, I assume SCHAR_MAX < INT_MAX and SHRT_MAX < INT_MAX respectively). Which of the functions below invoke undefined behavior and why? signed char test2(void) { signed char i = SCHAR_MAX; i = i + 1; /* implementation