This is the mail archive of the 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: changing "configure" to default to "gcc -g -O2 -fwrapv ..."

On 1/4/07, Richard Sandiford <> wrote:
Paul Eggert <eggert@CS.UCLA.EDU> writes:
> Mark Mitchell <> writes:
>> it sounds like that would eliminate most of the problem.  Certainly,
>> making -INT_MIN evaluate to INT_MIN, when expressed like that, is an
>> easy thing to do; that's just a guarantee about constant folding.
> Well, no, just to clarify: the GCC code in question actually computed
> "- x", and relied on the fact that the result was INT_MIN if x (an
> unknown integer) happened to be INT_MIN.  Also, now that I'm thinking
> about it, some the Unix v7 atoi() implementation relied on "x + 8"
> evaluating to INT_MIN when x happened to be (INT_MAX - 7).  These are
> the usual kind of assumptions in this area.

I don't know if you're implicitly only looking for certain types of
signed overflow, or if this has been mentioned elsewhere (I admit I had
to skim-read some of the thread) but the assumption that signed overflow
is defined is _very_ pervasive in gcc at the rtl level.  The operand to
a CONST_INT is a signed HOST_WIDE_INT, and its accessor macro -- INTVAL
-- returns a value of that type.  Most arithmetic related to CONST_INTs
is therefore done on signed HOST_WIDE_INTs.  This means that many parts
of gcc would produce wrong code if signed arithmetic saturated, for
example.  (FWIW, this is why I suggested adding a UINTVAL, which Stuart
has since done -- thanks.  However, most of gcc still uses INTVAL.)

I thought all ints are unsigned in the RTL world as there is I believe no way to express "signedness" of a mode. This would have to change of course if we ever support non two's-complement arithmetic.


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