tinny bug with naming conflict

Tiny thing, but it caused me a headake for almost an hour in my bigger project.

Although nvcc did thow warning messages, I didn’t see them at first among lots of other messages.

Note - without extra curly braces, nvcc will correctly report an error during compilation.

[codebox]

global void doSomething(float *c, int step) {

{

c[0]=step;

return;

int step=0;

++step;

}}

int main() {

doSomething<<<grid,block>>>(someFloatPointer,2);

}

[/codebox]

At the end of kernel call there should be 2 stored under someFloatPointer. Unfortunately, compiler tries to access local variable ‘step’, which is not even declared, instead of function argument, and sets some garbage to c[0].

Commenting instructions after ‘return’ brings back correct behaviour.