https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85696

            Bug ID: 85696
           Summary: OpenMP with variably modified and default(none) won't
                    compile
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-bugzilla at zulan dot net
  Target Milestone: ---

Created attachment 44085
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44085&action=edit
gcc -v (Archlinux)

The following trivial code

    void foo(int n, int a[][n])
    {
    #pragma omp parallel shared(a) default(none)
        a[23][0] = 42;
    }

fails to compile:

    $ gcc -c -fopenmp minimal.c 
    minimal.c: In function ‘foo’:
    minimal.c:3:6: error: ‘n.0’ not specified in enclosing ‘parallel’
         a[23][0] = 42;
          ^
    minimal.c:2:9: error: enclosing ‘parallel’
     #pragma omp parallel shared(a) default(none)
             ^~~

It appears that there is an internal copy n.0 of n to compute the index to any
further access to a. This internal copy is not handled properly in the
default(none) parallel region.

Interestingly in the 004t.gimple pass, it is actually listed as shared(n.0):

    #pragma omp parallel default(none) shared(a) shared(n.0)


The bug exists at least since 4.8 and was first reported at
https://stackoverflow.com/q/47081274/620382

Reply via email to