[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc
Subject:    Re: AMD64. sign extension correct?
From:       Andreas Schwab <schwab () suse ! de>
Date:       2005-02-27 21:20:37
Message-ID: jeis4d3dju.fsf () sykes ! suse ! de
[Download RAW message or body]

Claus-Justus Heine <ch@dot-heine.de> writes:

> 3.
> (signed long) = (signed int) x (unsigned int)
>
> Surprisingly the sign is not promoted in this case:
>
> a = -1 * 20, then a = 0x0000 0000 ffff ffec
>
>
> IMHO, this is a bug.

No, it's correct.  The type of the multiplication expression is unsigned
int, because signed int and unsigned int have the same integer conversion
rank, thus the common type is unsigned int and the signed int operand is
converted to unsigned int.  See 6.3.1.8 "Usual arithmetic conversions" in
the C standard.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic