Skip to content

[openmp][clang] Compilation error for omp update directive when multi dimension array is allocated on heap #144827

Open
@aywala

Description

@aywala
#include <stdio.h>
#include <stdlib.h>
  
int main() {
    int **a = (int**)malloc(100*sizeof(int*));
    for(int i=0;i<100;i++) {
        a[i] = (int*)malloc(100*sizeof(int));
    }
    for(int i=0;i<100;i++) {
        for(int j=0;j<100;j++) {
            a[i][j]=0;
        }
    }
  
    #pragma omp target data map(to: a[0:1][0:100])
        {
            #pragma omp target teams
                #pragma omp distribute
                    for (int j = 0; j < 100; j++) {
                        a[0][j] += j;
                    }
            #pragma omp target update from(a[0:1][0:100])
        }
 
    printf("a[0][10]: %d\n", a[0][10]);
}
<source>:22:44: error: section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound
   22 |             #pragma omp target update from(a[0:1][0:100])
      |                                            ^
1 error generated.

https://godbolt.org/z/KTxcv3MKE

note:
If you change a[0:1][0:100] to a[0][0:100] it will not diagnostic an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"clang:openmpOpenMP related changes to Clang

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions