This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: AMD64. sign extension correct?
- From: Falk Hueffner <falk at debian dot org>
- To: Claus-Justus Heine <ch at dot-heine dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 27 Feb 2005 22:07:27 +0100
- Subject: Re: AMD64. sign extension correct?
- References: <4222328A.9060702@dot-heine.de>
Claus-Justus Heine <ch@dot-heine.de> writes:
> (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 isn't. In this context, -1 is converted to unsigned, yielding
0xffffffff. Then 0xffffffff * 20 is calculated and truncated to
unsigned, and then zero extended to 64 bit.
--
Falk