right/left shifts with (width of type)
Stefan Meixner
Stefan.Meixner@emskopp.a.shuttle.de
Thu Jul 2 05:01:00 GMT 1998
Hi,
right now I will not call it a bug, but gcc/egcs
practise with right/left shifts with counts equal
to the width of the type is at least not protable
(at least on a i486-pc-linux-gnulibc1 where I tested it).
I would expect the following expression to hold
for both << and >> operators
unsigned long u = ~0;
if ( (u << (sizeof(unsigned long)*CHAR_BIT)) == 0 )
printf("GOOD");
else
printf("BAD");
At least this is the behavior I would expect and I get from
the other compilers I tested.
I know that this maybe implementation defined. But shifting
any unsigned long by count=width, the result should be zero.
Am I wrong?
Thanks for listening!
Stefan
More information about the Gcc-bugs
mailing list