This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: AMD64. sign extension correct?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]