This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
bug?
- To: gcc-help at gcc dot gnu dot org
- Subject: bug?
- From: Ben Kohlen <bckohlen at yahoo dot com>
- Date: Fri, 15 Jun 2001 15:57:30 -0700 (PDT)
I am expecting that when I shift right, I will always
get zeroes in from the left, but when I use data types
less than 32 bits, this is not always the case.
Example:
...
unsigned short s = 0xcc55;
printf("%x\n", (s<<8)>>8);
...
yeilds the output "cc55" where as I was expecting
"55".
I was expecting this to be equivalent to:
...
s = s << 8;
s = s >> 8;
...
in which you do explicit assignment, which does yeild
"55" as the output.
Is this part of C spec, unspecified by C, or actually
a gcc bug?
gcc version 2.95.3 20010315 (release) on an x86 btw.
Please CC responses, as I am not on the list.
Cheers,
Ben
__________________________________________________
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/