Strange Bug


the following small example shows a bug that shows up in a kernel:

kernel void example_kernel (global read_only float* some_input_data, global read_only unsigned int* index_to_data, global write_only float* some_output_data) {
        unsigned int lid = get_local_id (0);
        some_output_data [lid] = source_data [index_to_data [lid]];//error
        //some_output_data [lid] = source_data ["place literal of index_to_data [lid] here"];//ok
        //some_output_data [lid] = index_to_data [lid]; //ok, shows correct index

What could be the reason for this error? I’m pretty clueless here.

It would help if you told us what the error was.

I get a CL_INVALID_COMMAND_QUEUE error on call to clFinish (my_command_queue) right after launching the above kernel.

Eventually I found the bug: I was writing to out-of-range indices in the some_output_data buffer. It’s still a bit strange why it didn’t crash in the other two cases.