What does the C standard say happens when a signed int overflows, as in INT_MAX + 1?
Correct answer C. The behaviour is undefined
Explanation
Signed integer overflow is undefined behaviour in C, so the compiler may assume it never happens and optimise accordingly, for example removing a check such as x + 1 > x. Wrapping to INT_MIN is what the hardware often does, but it is not guaranteed. Unsigned arithmetic, by contrast, is defined to wrap modulo 2 to the power of the width.
Answer checked How we write and check questions
Discussion