2 ms·
Signed overflow is undefined, unsigned overflow is defined. But I agree with you. Not enough people take integer overflow seriously. Unsigned underflow, perfec
by barrkel 12y ago
Signed overflow is undefined, unsigned overflow is defined. But I agree with you. Not enough people take integer overflow seriously.
Unsigned underflow, perfectly well defined behaviour, is actually a worse problem in practice, IMO. I think too many C programers think about unsigned types like they're a bounded type, e.g. they think "this variable can never be negative, therefore I'll give it an unsigned type". But unsigned types have a cliff of surprising behaviour right where they're commonly used - most integer values in programs are low. Whereas you really need to work on a signed value to get it to overflow.