Compiler incorrectly accepts initialized local variables

Compiler incorrectly accepts initialized local variables

When compiling the following snippet the offline compiler does not complain:

__kernel void T6_f_15_355 () {
    __local   int x   = 5 ;
  x = 0;

According to the OpenCL 1.1 spec (6.5.2), a local variable cannot be initialized.

The AMD compiler emits an error:

Line 2: error: variable "x"
          may not be initialized
      __local   int x =1  ;

1 error detected.

Moreover, local variables should only be defined at kernel function scope. The following code should thus also be rejected:

__kernel void T6_f_15_355 (int x) {
   if(x < 3) {
      __local int y  ;
      y = 0;

But all OpenCL compilers seem to accept it without complaining.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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.

Guy Benyei

Leave a Comment

Please sign in to add a comment. Not a member? Join today