O
Old Wolf
SuperKoko said:Do you even know that signed integer overflow is UB.
For instance:
signed char c=127;
++c; // undefined behavior (assuming that MAX_CHAR is 127).
(There is no such thing as MAX_CHAR, I guess you mean CHAR_MAX).
This is assignment of an out-of-range value, and is implementation-
defined. Integer overflow would be:
int m = INT_MAX;
++m;
When evaluating your ++c, c is promoted to integer before
applying the ++ operator. The integer 127 can be incremented
to 128 successfully. Then when 128 is reassigned to c, the
out-of-range assignment occurs.