Strange enum type conversion

Richard Earnshaw rearnsha@arm.com
Thu Dec 3 15:01:00 GMT 2009


On Thu, 2009-12-03 at 04:22 -0800, John (Eljay) Love-Jensen wrote:
> Hi Hajo,
> 
> Normal promotion rules apply.
> 
> You have both:
> 1 << 31 (which is a signed int)
Correct (on a machine with 32 bit int)

> 0xFFFFFFFF (which is an unsigned int)

wrong.  That's an int with a bit pattern that's all 1's.  On a two's
complement machine with 32-bit ints that's equivalent to -1.

If you want an unsigned value you need 0xFFFFFFFFU

R.




More information about the Gcc-help mailing list