[PATCH] Document arithmetic overflow semantics
Richard Kenner
kenner@vlsi1.ultra.nyu.edu
Thu Feb 13 13:24:00 GMT 2003
+ For integral types, negation is the same as subtraction from zero.
+ Because the range of two's-complement values in not symmetric, the
+ negation of the maximum negative integer results in the same maximum
+ negative number.
I *really* don't like defining the tree operations as having this overflow
behavior. I have three major problems with it:
(1) It removes the potential of optimizations that assume such overflow cannot
occur in languages where it is undefined (C, C++, and Ada).
(2) It represents an implementation difficulty and perhaps cost on machines
where this behavior is not present (for example, where it traps).
(3) It does not allow representing trapping arithmetic in the three.
My suggestion is to use a bit in either the type (my preference) or the
operation to say whether overflow is defined or not. There can be a bit in
the operation to require that it trap if it overflow.
More information about the Gcc
mailing list