Practice mode C Language

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.