This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Where does the C standard describe overflow of signedintegers?
- From: Paul Koning <pkoning at equallogic dot com>
- To: schlie at comcast dot net
- Cc: dewar at adacore dot com, mattheww at chiark dot greenend dot org dot uk, gcc at gcc dot gnu dot org
- Date: Thu, 14 Jul 2005 16:35:52 -0400
- Subject: Re: Where does the C standard describe overflow of signedintegers?
- References: <42D6B970.1090903@adacore.com><BEFC351B.AD1A%schlie@comcast.net>
>>>>> "Paul" == Paul Schlie <schlie@comcast.net> writes:
>> From: Robert Dewar <dewar@adacore.com>
>>> Paul Schlie wrote:
>>>> What about optimising x*2/2 to x?
>>> Given that "C" requires the above be evaluated as (x*2)/2, as the
>>> language specifies that the syntax defines the precedence of the
>>> operations, and that no optimization should alter the behavior as
>>> specified by the program; I'd say that unless it was known that
>>> the value range of x was between 0 and INT_MAX, the optimization
>>> is simply invalid.
>> the optimization is indeed valid
>>
>> optimizations may most certainly alter behavior of undefined
>> code. think about uninitialized local variables.
Paul> I don't contest that it may, I simply don't believe it should.
In that case you may want to stick with -O0. There are *lots* of
things GCC does that alter undefined cases. How about the undefined
behavior when aliasing rules are violated? Would you want to make
-fno-strict-aliasing be the only supported setting?
paul