AtomicOr sets wrong bits...

Hello,

Here is my code (which is part of the kernel run):

void setIsAnswer(MY_LONG ansId, unsigned int *ansTable) {
MY_LONG intNum = ansId/(sizeof(unsigned int)8);
unsigned int remainder = ansId%(sizeof(unsigned int)8);
unsigned int orVal = 0;
orVal= orVal | 1<<remainder;
unsigned int debug = ansTable[intNum];
ansTable[intNum]=debug;
atomicOr(ansTable/
+intNum
/,orVal);
debug = ansTable[intNum];
ansTable[intNum] = debug;
return;
}

I have a case when orVal==1 and intNum==0 and ansTable[0]=0. Also the size of ansTable is exactly 1.
So after the atomicOr, the result of ansTable[0] has to be 1. but it is 65537. I.e. not only bit 0 was set but also bit 16… The size of int is 4 bytes.

Any ideas?

Thank you in advance, Lila

Found the bug! thanks everybody.