[PATCH] Document arithmetic overflow semantics

Richard Earnshaw rearnsha@arm.com
Thu Feb 13 16:22:00 GMT 2003


> In C, it is frequently the case that defining the overflow behavior of
> signed integer in this way makes more optimizations possible.  For one
> thing, it makes addition and multiplication associative.  Without such
> an assumption, you can't turn (a+b)+c into a+(b+c), because the overflows
> might be different.

The same is also true if the operation saturates.  I don't recall anything 
in the C89 standard that says that signed arithmetic can't be implemented 
on a saturating arithmetic machine.

R.




More information about the Gcc mailing list