<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/114890>114890</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][OpenMP] Incorrect execution result when multiple associate and parallel private constructs are nested
</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-new : 20.0.0(5621929f7f4878c318deecb592cd03f5ecbb83ba)/AArch64
```
When multiple `associate` and `parallel private` constructs are nested, the value of `association` is incorrect.
The above program is `FT_openmp_private_09_21.f90`
When `associate` construct is not nested, the result is correct.
The above program is `FT_openmp_private_09_22.f90`
The following are the test program, Flang-new, Gfortran and ifx compilation/execution result.
FT_openmp_private_09_21.f90:
```fortran
program main
integer :: b(3)=5
integer :: d=10
real :: f=15
associate(c=>d, a=>b(2:3))
!$omp parallel private(b,d,f)
associate(e=>f)
!$omp parallel private(f)
b=7
d=8
f=9
if(e .ne. 15) print*,"104",e
!$omp end parallel
end associate
if(a(1) .ne. 5) print*,"101"
if(a(2) .ne. 5) print*,"102"
if(c .ne. 10) print*,"103",c
!$omp end parallel
print*, "pass"
end associate
end program main
```
```
$ export OMP_NUM_THREADS=2; flang-new -fopenmp FT_openmp_private_09_21.f90; ./a.out
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
104 1.54E-43
104 6.3116734E-19
pass
$
```
```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp FT_openmp_private_09_21.f90; ./a.out
104 2.25024438
104 0.00000000
pass
$
```
```
$ export OMP_NUM_THREADS=2; ifx -qopenmp FT_openmp_private_09_21.f90; ./a.out
pass
$
```
FT_openmp_private_09_22.f90:
```fortran
program main
integer :: b(3)=5
integer :: d=10
real :: f=15
associate(c=>d, a=>b(2:3),e=>f)
!$omp parallel private(b,d,f)
! associate(e=>f)
!$omp parallel private(f)
b=7
d=8
f=9
if(e .ne. 15) print*,"104",e
!$omp end parallel
! end associate
if(a(1) .ne. 5) print*,"101"
if(a(2) .ne. 5) print*,"102"
if(c .ne. 10) print*,"103",c
!$omp end parallel
print*, "pass"
end associate
end program main
```
```
$ export OMP_NUM_THREADS=2; flang-new -fopenmp FT_openmp_private_09_22.f90; ./a.out
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
pass
$
```
```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp FT_openmp_private_09_22.f90; ./a.out
pass
$
```
```
$ export OMP_NUM_THREADS=2; ifx -qopenmp FT_openmp_private_09_22.f90; ./a.out
pass
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsV09v47YT_TT0hbBADiVZOvjgxPHv10O6izbtHg1KHtlc0KRKUkn67QvqT-I4aZrdbZFFUSNIlCFn3nvk8FmU3qu9QVyS7IJk65nswsG6pT0YO28-zyq7-31Jcjb-sDVhq1_ReWUNtQ1ttDT7ucE7SsSKAktYwggUWQ68hLJZNGmxKGrBix1iXWUl1DsmmgzrqipEJQmUBDarlasPeToUP8Mafn86oKHHTgfVaqQkZ9J7WysZkOSMSrOLsVY6qTVq2jp1Ow7V1vjgujp4Kh1Sgz7gjsAlDQekt1J3GFWcFFTWxDzlqTK1dQ7rkFA6sLg5IJWVvUXaOrt38hinkZxtbra2RXNstyPylpVb4ElTRh1Tdq_hnPoDv1jK2HDG0KHvdD_2bVzgjMtjjcZqbe-U2ffrEzED-jAVjTw20xbHf_7XWBecNP2aq-ae1vbYKj2sG2zwHusuPo_Mk1O415ZJrM52f8QZopPEo1RjhCoTcI8utl3svIpAIWI3iXU2zjifsiNizdk06FBqSuk02MTBKfNxh6CoiVgTcdXviByeIxYQserxoByJAyeQ2mNLn7UhFBWBy1iheZj-BAOHus3bip0U6T8VEevFaSAKLcZA1PVktmoiIKWJwYTyjEAZS5tAYEXgkgBwlhIAApd4zgXN7oHPWDKGHpU8wPQgkk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