[PATCH] Document arithmetic overflow semantics
Richard Kenner
kenner@vlsi1.ultra.nyu.edu
Thu Feb 13 16:09: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.
True, but there are an equal number of simplification that can only be done
if you are allowed to assume that overflow is undefined.
Perhaps an approach might be to say that "we know what overflow
actually does for this operation, but if it occurs, it's undefined
semantics". That's what we actually *implement* right now and would
give the best of both worlds. Then there would be a bit that says that,
in this particular operation, the overflow is *not* undefined.
More information about the Gcc
mailing list