This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Shifting: what's going on?
- From: John Love-Jensen <eljay at adobe dot com>
- To: Facundo Ciccioli <facundofc at gmail dot com>, Andrew Haley <aph at redhat dot com>
- Cc: MSX to GCC <gcc-help at gcc dot gnu dot org>
- Date: Thu, 29 Mar 2007 10:06:46 -0500
- Subject: Re: Shifting: what's going on?
Hi Facundo,
> I expect to get a 1 in the s-th bit of a, and zeroes in all other
> bits. I don't know why you say that's an arithmetic overflow, if
> unsigned long long is 64 bits long and it has a 63-th bit (the last
> one).
You are not dealing with an unsigned long long that is 64-bits.
You are dealing with a signed int that is 32-bits.
Shifting a number by an amount equal-to-or-greater-than its bitsize has
undefined behavior.
--Eljay