symbol is not found?

I wrote a program with CPU in C++
and then i would like to make some change therefore it can be run in GPU

Although no error in prompt after compiling, break point is triggered after some code is run.

Then i found that all variables declared in the function are actually not declared. When i put it in Watch, it indicated that the symbol is not found.

However, this function is not for GPU.

For example:
void add_all(int a)
{
int i = a;
char * temp = (char*)malloc(sizeof(char)*i);

}

then it said that “i” and temp is not found.

Could anyone give me a solution on this??

Thanks