This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]