Can't return 0xffffffff value from kernel 0xffffffff cant be put in uint var?

This topic is closely related to float -> uint conversion topic posted by me recently, however, I’m knowingly putting this question into the root.

When I do something like this:

global void kernel(unsigned int* pOut)
{
pOut[nThreadIdx % nOutSize] = 0xffffffff;
}

I get 0xcdcdcdcd values in pOut instead of 0xffffffff.

Why this happens ?

0xcdcdcdcd looks like uninitialized memory to me. Are you copying the value back with cudaMemcpy?

Arghhh …

I can hardly believe it - mixed up source and destination pointers in cudaMemcpy! I have no words.