checking for overflow in C

Doug Gwyn gwyn at smoke.BRL.MIL
Thu May 18 07:55:13 AEST 1989


In article <472 at chem.ucsd.EDU> tps at chem.ucsd.edu (Tom Stockfisch) writes:
>Aren't unsigned int operations guaranteed not to generate exceptions?

C guarantees that unsigned integer arithmetic is performed as modular
arithmetic.

>It seems like the C compiler could/should have done things differently.

Bascially, to avoid relying on benign integer overflow behavior would
have required slower code to be generated.  Several C implementations
have made this same decision.



More information about the Comp.lang.c mailing list