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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Incorrect execution result when assumed-shape array is allocated and defined in parallel construct with private clause
        </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 : 22.0.0(9e5f9ff82f2f060aac73a965ab37fdbb6b53cfe0)/AArch64
```

In the attached program (`snggk070_2.f90`), `assumed-shape array (a) `is allocated and defined in `parallel construct` with `private clause`, but no value is assigned to array (a).

The result is correct if:
- do not specify the `-fopenmp` option


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

snggk070_22.f90:
```fortran
subroutine sub(i,j)
 character(i),pointer::a(:,:)
!$OMP PARALLEL PRIVATE(a)
  allocate(a(i,j)); a="abc"
  write(6,*) "a = ", a
  deallocate(a)
!$OMP END PARALLEL
end subroutine sub

program main
  call sub(3,4)
  print *,'pass'
end program main
```

The following is with the `-fopenmp option`:
```
$ export OMP_NUM_THREADS=2; flang -fopenmp snggk070_22.f90; ./a.out
 a =
 a =
 pass
$
```

The following is without the `-fopenmp option`:
```
$ flang snggk070_22.f90; ./a.out
 a = abcabcabcabcabcabcabcabcabcabcabcabc
 pass
$
```

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

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

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.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