On Wed, Jul 20, 2005 at 11:57:51AM +0200, Verdi March wrote:
Hi, the following is compiled in 9.3, glibc-2.3.4-23.4, and gcc-3.3.5-5. The result is: mask=0 mask1=4294967295
I would expect mask = mask1 = 0?
Regards, Verdi
=========================================================== #include
int main() { unsigned int mask = (unsigned int) -1 >> 32;
int i = 0; unsigned int mask1 = ((unsigned int) -1) >> (32 - i);
printf("mask=%u mask1=%u\n", mask, mask1); return 0; } ===========================================================
A shift count exceeding the width of the entity is undefined. Aka, shiftcount >= 32 is undefined. $ gcc -Wall -O2 -c xx.c xx.c: In function #main#: xx.c:4: warning: right shift count >= width of type $ The second time you are tricking the compiler, but its similar. Ciao, Marcus