This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Document arithmetic overflow semantics
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: roger at www dot eyesopen dot com
- Cc: gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Thu, 13 Feb 03 08:08:30 EST
- Subject: Re: [PATCH] Document arithmetic overflow semantics
+ 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.