opencl compiler crash when compiling with write_imagef in the opencl device-code

a strange compiler crash occurs when I try to compile my device code which contains this line:

write_imagef( OutputImage, (int2)(x,y), color );
return;

This instruction is located in an aabb-tree based traversal algorithm used for casting shadow-rays.
the first time a triangle is hit the above code should write to the output image and return immediately from the kernel.
but somehow the compiler crashes without any warning during the following call in the host-code:

crash point → if (clBuildProgram(program, 0, NULL, NULL, NULL, NULL) != CL_SUCCESS)

I traced the call-stack as well: it crashes inside one of the nvidia dll’s…

I got around this problem by writing a separate function like this:

void WriteColor(__write_only image2d_t OutputImage, int2 pos, float4 color)
{ write_imagef( OutputImage, pos, color ); }

and replaced the first code as

WriteColor( OutputImage, (int2)(x,y), color );
return;

this works fine.
but still, I am worried if there could be any problems with more complicated codes in the future.
any ideas?