This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]