This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
rshift problem
- From: "John Kacur" <jkacur at gmail dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 18 May 2008 20:24:58 +0200
- Subject: rshift problem
cat rshift.c
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
unsigned j = ~0 >> 8;
unsigned i = ~0;
i >>= 8;
printf("i = %x\n", i);
printf("j = %x\n", j);
exit(0);
}
gcc -o rshift rshift.c -Wall -g
jkacur@athena:~/b1systems/ckurs> ./rshift
i = ffffff
j = ffffffff
jkacur@athena:~/b1systems/ckurs> gcc --version
gcc (GCC) 4.2.1 (SUSE Linux)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Am I just doing something wrong? Why aren't i and j equal?