rshift problem

John Kacur jkacur@gmail.com
Sun May 18 18:25:00 GMT 2008


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?



More information about the Gcc-bugs mailing list