This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Document arithmetic overflow semantics
- From: Joe Buck <jbuck at synopsys dot com>
- To: Robert Dewar <dewar at gnat dot com>
- Cc: roger at www dot eyesopen dot com, gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org, kenner at vlsi1 dot ultra dot nyu dot edu
- Date: Thu, 13 Feb 2003 11:42:11 -0800
- Subject: Re: [PATCH] Document arithmetic overflow semantics
- References: <20030213191010.84EA2F2DA2@nile.gnat.com>
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.