Thanks for taking time to read this. I have 2 kernels. To both these kernels I send the same 2 memory buffers as arguments, where each of the memory buffers have the size -> sizeof(int) * 10.

I call init_mpm( ) first and I set m[i] to the subsequent address locations in bmasks. Basically I am holding an array of addresses.

I next call resolve_address( ) and I assign the value m[i], which actually now holds the address values from bmasks from the previous call to init_mpm( ) to a pointer p. But now when I try to resolve the pointer as p[0], I get clBuildProgram error of -42. Can't I resolve the address like this? Isn't p now holding the address and can't it be resolved as an integer using p[0]? I am actually trying to hold an array of address from a memory object across multiple kernel invocations and later resolve these addresses in another kernel.

__kernel void init_mpm(__global int *m, __global int *bmasks)
{
unsigned int i = 0;

for (i = 0; i < 10; i++) {
bmasks[i] = i;
m[i] = bmasks + i;
}
}

__kernel void resolve_address(__global int *m, __global int *bmasks)
{
unsigned int i = 0;
__global int *p;

for (i = 0; i < 10; i++) {
p = m[i];
m[i] = p[0]; <-- this line gives me an error. If I comment this line I get no errors during compilation
}

}