PR c/6677 and al.

Richard Henderson rth@redhat.com
Wed May 29 11:18:00 GMT 2002


On Wed, May 29, 2002 at 11:07:02AM +0200, Eric Botcazou wrote:
> Do you mean that [int being 32-bit]
> 
>   int i = 0x7fffffff;
>   int j;
> 
>   j = (i << 1) / 2;
> 
> is allowed to return j = 0x7fffffff ?

Yes.  Overflow of signed arithmetic is undefined.

> The problem is that we don't look through the narrowing cast in the fist
> case: (i<<1):QI is really transformed into (i:QI) << (1:QI), which is valid
> per se.

Except that it isn't, due to the above non-definition of signed arithmetic.


r~



More information about the Gcc-patches mailing list