autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."


From: Richard Sandiford
Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
Date: Thu, 04 Jan 2007 11:34:18 +0000
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

Paul Eggert <address@hidden> writes:
> Mark Mitchell <address@hidden> 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.)

Richard




reply via email to

[Prev in Thread] Current Thread [Next in Thread]