Problem in Release compile not in EmuDebug Advisory: Cannot tell what pointer point

//C code(hello.cpp):

typedef struct g_states_t 

{

	int i; 

	struct g_states_t *pnext;

}g_state;

typedef struct ST

{

	g_states_t **cur;

	g_states_t *ctx[4];

}ST;

void setstates(ST *ps, g_states_t states[4])

{

	for (int i = 0; i < 4; i++)

	{

  ps->ctx[i] = &states[i];

	}

} 

void main(int argc, char * argv[])

{

	g_states_t states[4] = 

	{

  {400, &states[1]},

  {401, &states[2]},

  {402, &states[3]},

  {403, &states[0]}

	};

	ST s1, *ps1;

	ps1 = &s1;

	setstates(ps1, states);

	ps1->ctx[2]->i = 123;

	ps1->ctx[2]->pnext = &states[0];

	ps1->ctx[3]->pnext->i = 456;

	printf("%d\n", ps1->ctx[2]->i);//ok,output:123

	printf("%d\n", ps1->ctx[2]->pnext->i);//ok,output:456

	printf("%d\n", ps1->ctx[3]->pnext->i);////ok,output:456

	printf("hello");

}

/////////////////////////////////////////////

//GPU code(kernel.cu):

typedef struct g_states_t 

{

	int i; 

	struct g_states_t *pnext;

}g_state;

typedef struct ST

{

	g_states_t **cur;

	g_states_t *ctx[4];

}ST;

__device__ 

void setstates(ST *ps, g_states_t states[4])

{

	for (int i = 0; i < 4; i++)

	{

  ps->ctx[i] = &states[i];

	}

}

__global__ 

void kernel()

{

	g_states_t states[4] = 

	{

  {400, &states[1]},

  {401, &states[2]},

  {402, &states[3]},

  {403, &states[0]}

	};

	ST s1, *ps1;

	ps1 = &s1;

	setstates(ps1, states);

	ps1->ctx[2]->i = 123;//err

	ps1->ctx[2]->pnext = &states[0];//err

	ps1->ctx[3]->pnext->i = 456;//err

}

/////////////////////////////////////////////////////////////////////////////////

When compile the GPU code in Release mode,prompt:

1>------ 已启动生成: 项目: cu_blank_forTest, 配置: Release Win32 ------

1>正在执行自定义生成步骤

1>cu_host.cu

1>tmpxft_00001ae8_00000000-3.gpu

1>tmpxft_00001ae8_00000000-7.gpu

1>“E:\MYWIND~1\TEMP/tmpxft_00001ae8_00000000-8.i”, line 43: Advisory: Cannot tell what pointer points to, assuming global memory space

1>“E:\MYWIND~1\TEMP/tmpxft_00001ae8_00000000-8.i”, line 44: Advisory: Cannot tell what pointer points to, assuming global memory space

1>“E:\MYWIND~1\TEMP/tmpxft_00001ae8_00000000-8.i”, line 45: Advisory: Cannot tell what pointer points to, assuming global memory space

1>“E:\MYWIND~1\TEMP/tmpxft_00001ae8_00000000-8.i”, line 45: Advisory: Cannot tell what pointer points to, assuming global memory space

1>tmpxft_00001ae8_00000000-3.c

1>tmpxft_00001ae8_00000000-12.i

1>正在链接…

1>正在嵌入清单…

1>生成日志保存在“file://d:\Working\cu_blank_forTest\cu_blank_forTest\Release\BuildLog.htm”

1>cu_blank_forTest - 0 个错误,0 个警告

========== 生成: 1 已成功, 0 已失败, 0 最新, 0 已跳过 ==========

What’s the reason, please?

When you have pointers to pointers, the compiler can’t know whether they point to global or shared memory. There is no way in CUDA 1.1 to tell it one way or another, so you have to live with the warnings.

typedef struct g_states_t 

{

int i; 

struct g_states_t *pnext;

}g_state;

typedef struct ST

{

g_states_t **cur;

g_states_t *ctx[4];

}ST;

__global__ void

kernel()

{

	g_states_t states[4] = 

	{

 Â {400, &states[1]},

 Â {401, &states[2]},

 Â {402, &states[3]},

 Â {403, &states[0]}

	};

	ST s1, *ps1;

	ps1 = &s1;

	//setstates(ps1, states);

	//////////////////////////////////////////////////////////////////////////

	//[A],ok

	ps1->ctx[0] = &states[0];

	ps1->ctx[1] = &states[1];

	ps1->ctx[2] = &states[2];

	ps1->ctx[3] = &states[3];

	

	//[B], error

// Â for (int i = 0; i < 4; i++)

// Â {

// Â Â ps1->ctx[i] = &states[i];

// Â }

	//////////////////////////////////////////////////////////////////////////

 Â ps1->ctx[2]->i = 123;

 Â ps1->ctx[2]->pnext = &states[0];

 Â ps1->ctx[3]->pnext->i = 456;

}

采用for循环的方式的时候,就同调用setstates()å‡½æ•°ä¸€æ ·,出现编译错误.

而当采用将for循环展开的方式进行初始化的时候,编译就没有问题.

Release mode:

When use for loop to init (part [B]),like use setstates(),prompt the same err.

But when I use the part [A], there’s no err,faint.

What’s the difference between A and B, Why?