Machine-translated by Google. Questions are authored in English.
Top

Discussion

Signed integer overflow in C is

  • A.guaranteed to wrap to the most negative value
  • B.guaranteed to saturate at the maximum value
  • C.guaranteed to raise an implementation-defined signal
  • D.undefined behaviour

Answer: D

Unsigned arithmetic wraps by definition; signed overflow is undefined, and modern optimisers exploit that to assume it cannot happen. Code that relies on signed wrapping can therefore be transformed in surprising ways.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.