Where does the C standard describe overflow of signed integers?

Robert Dewar dewar@adacore.com
Thu Jul 14 19:13:00 GMT 2005


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.



More information about the Gcc mailing list