Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Philippe
Beginner
51 Views

Compiler incorrectly accepts initialized local variables

When compiling the following snippet the offline compiler does not complain:
[cpp]__kernel void T6_f_15_355 () {
    __local   int x   = 5 ;
  x = 0;
  return;
}[/cpp]
According to the OpenCL 1.1 spec (6.5.2), a local variable cannot be initialized.

The AMD compiler emits an error:
[plain]Line 2: error: variable "x"
          may not be initialized
      __local   int x =1  ;
                    ^

1 error detected.
[/plain]
Moreover, local variables should only be defined at kernel function scope. The following code should thus also be rejected:
[cpp]__kernel void T6_f_15_355 (int x) {
   if(x < 3) {
      __local int y  ;
      y = 0;
   }
}[/cpp]
But all OpenCL compilers seem to accept it without complaining.
0 Kudos
1 Reply
Guy_B_Intel
Employee
51 Views

Hello Phillippe,
Thanks for your post, I'll open a bug report on this issue, and we'll add these restrictions to one of our future versions.

Thanks
Guy Benyei