[PATCH] Document arithmetic overflow semantics
Joe Buck
jbuck@synopsys.com
Thu Feb 13 19:47:00 GMT 2003
On Thu, Feb 13, 2003 at 02:10:10PM -0500, Robert Dewar wrote:
> > But undefined overflow is a superset of two's complement semantics
>
> I don't understand the terminology here. Are you using "two's comlement" to
> imply unsigned wrap around, i.e. throw away carry and ignore overflow. If so,
> that's a bit confusing, since it presupposes the conclusion. The issue with
> twos complement signed arithmetic is preciesely what happens on overflow (that's
> the only thing that distinguishes it from unsigned).
To clarify: if we have code that might overflow, we can generate a
variety of different forms of assembler language, as long as the
cases that don't overflow compute the correct results. One of the
possibilities is to generate a two's complement addition. Another
is to generate a trapping addition.
If we use two's complement addition, which is associative, we can make
further transformations.
More information about the Gcc
mailing list