<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/143330>143330</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Execution error when array assignment statement for an array containing ":" is specified in forall construct within workshare construct
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:openmp
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang : 21.0.0(b68565b8c70fc590f8e59799996f450b1072b532)/AArch64
```

In the attached program (`snggw638_220.f90`), when `array assignment statement` for an array containing `":"` is specified in `forall construct` within `workshare construct`, the execution terminates abnormally.

Execution ends normally in the following cases:
- No compilation option (`-fopenmp`)
- Change the value specified for `OMP_NUM_THREAD` from `2` to `1`
- Change `":"` to array subscripts (`1` and `2`)
  see `snggw638_221.f90` below.
- Change `":"` to loop variable (`n0`) and add loop (`forall(n0=1:2) / end forall`)
  see `snggw638_222.f90` below.

The combination of `OpenMP workshare construct` and `array assignment statement` for an array containing `":"` in `forall construct` does not appear to work correctly.

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

snggw638_220.f90:
```fortran
program main
  integer a1(2,1,3)
 a1 = 0
!$omp parallel
!$omp workshare
  forall (n1=1:1)
     forall (n2=1:3)
        a1(:,n1,n2) = a1(:,n1,n2)+1
     end forall
  end forall
!$omp end workshare
!$omp end parallel
  print *,'pass'
end program main
```

```
$ export OMP_NUM_THREADS=2; flang -fopenmp snggw638_220.f90; ./a.out
Segmentation fault (core dumped)
$
```

```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp snggw638_220.f90; ./a.out
 pass
$
```

```
$ export OMP_NUM_THREADS=2; ifx -qopenmp snggw638_220.f90; ./a.out
 pass
$
```

snggw638_221.f90:
```fortran
program main
  integer a1(2,1,3)
  a1 = 0
!$omp parallel
!$omp workshare
  forall (n1=1:1)
 forall (n2=1:3)
!        a1(:,n1,n2) = a1(:,n1,n2)+1
        a1(1,n1,n2) = a1(1,n1,n2)+1
        a1(2,n1,n2) = a1(2,n1,n2)+1
     end forall
  end forall
!$omp end workshare
!$omp end parallel
  print *,'pass'
end program main
```

```
$ export OMP_NUM_THREADS=2; flang -fopenmp snggw638_221.f90; ./a.out
 pass
$
```

snggw638_222.f90:
```fortran
program main
  integer a1(2,1,3)
  a1 = 0
!$omp parallel
!$omp workshare
  forall (n0=1:2)
 forall (n1=1:1)
        forall (n2=1:3)
!           a1(:,n1,n2) = a1(:,n1,n2)+1
           a1(n0,n1,n2) = a1(n0,n1,n2)+1
        end forall
 end forall
  end forall
!$omp end workshare
!$omp end parallel
 print *,'pass'
end program main
```

```
$ export OMP_NUM_THREADS=2; flang -fopenmp snggw638_222.f90; ./a.out
 pass
$
```


</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkV9uO2zYTfprxzWANcmTJ0oUvtOv4_3uRNGjS3gaURB1SiVRJap28fUEdNrZ3nTSICwQoYFiH4Rz4zTejobC2qZSUOwjvIdyvxOBqbXa6Vvqu_LjKdPF5BxGbfyz9QxrbaIW6xLIVqkIIUiS-ZmsGFGdRHEZhFudbVuZhwspYhsk2SZIkKjchyzjbUhYGBJQAHdLU5HW0AZaeegCW_qLQ1RKFcyKvZYG90ZURHQLFEDGrquoYBfEHIrYuk1HN23vAYy0VQsSEMeIzTlvrpHJonXDS30HEsNQGhcJpUa6VE41q_E68HYIg9f8Rw8ai7WXelI0ssBkNl9qItvVK1pkhH80dG1dP0qM2f9paGHm2wAfmdyM_yXxwHjsnTdco4aRFkSltOtG2n9fT1l89rZKqsLhIvX9vpNRtq48-2lxYaX2wLL3DNxpz3fVNK0ZV3Y-XCa67UvdSdf0Mk1_-UAtVydHgo2gHebJPDw5E7NfXbz-8-f31h_f__-1Vuh9RM7rzkhEap_0tnxL2ZO8SQKdnkO2Q2dw0vbNzTF4ThSoWg1N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