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: X86_64 bit shifts


On Fri, Jul 06, 2007 at 06:06:43AM -0600, Wachdorf, Daniel R wrote:
>     val = (1 << 31);

Try 1UL << 31 instead.

> Should the result be 0x80000000?  I understand that the bit shift is a
> 32 bit operation, but shouldn't the compiler then up convert that to a
> 64 bit unsigned long?

No, a signed 32-bit integer is always sign extended when promoted to
64-bit.  If you have C99 handy, see section 6.3.1.3 (Signed and
unsigned integers).

-- 
Daniel Jacobowitz
CodeSourcery


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