24 bits shift: help me!

Dear all,

I have a strange behaviour using a bit shift of 24 bits.
In my program an unsigned int (chkword1), in the local register, is built on bit by bit basis with something like this:

chkword1 = chkword1|1<<i0;

This is in a loop where i0 can change. At a given stage chkword1 is
0000 0000 0111 0011 0010 1010 1111 0011
the next step will be for i0=24, after that chkword1 become:
0000 0000 0111 0011 0010 1010 1111 0100
instead of the correct value
0000 0001 0111 0011 0010 1010 1111 0011

do you have any idea why this happens?

thank you for any suggestion.


PS I have CUDA 3.2 with TESLA C1060

You might be able to gather some more information about the problem if you break up this line of code:

chkword1 = chkword1|1<<i0;

into two steps; assign the shifted value to a temporary variable, then check the value of it to make sure it’s correct:

unsigned int shiftedOne = 1 << i0;

chkword1 |= shiftedOne;