This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Document arithmetic overflow semantics


> 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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]