Issue 178790
Summary [Flang][OpenMP] Incorrect execution result when parallel construct containing private clause with common block is nested inside parallel construct containing firstprivate clause with common block
Labels flang:openmp
Assignees
Reporter ohno-fj
    ```
Version of flang : 23.0.0(e5d235831dfb07b6e767812af7f9d3daa5896f78)/AArch64
```

In the attached program (`snefe018_2.f90`), when `parallel construct` containing `private clause` with `common block (/com/)` is nested inside `parallel construct` containing `firstprivate clause` with `common block (/com/)`, the executi
on result is incorrect.

The execution result is correct in the following cases:
- Remove the inner `parallel construct`
The above is `snefe018_21.f90`.

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

snefe018_2.f90:
```fortran
program main
  integer a, b
  common /com/ a,b
  a=1
  b=2
!$omp parallel firstprivate(/com/)
  write(6,*) "1 : a = ", a, ", b = ", b
!$omp parallel private(/com/)
!$omp end parallel

!$omp end parallel
 write(6,*) "2 : a = ", a, ", b = ", b
end program main
```

```
$ export OMP_NUM_THREADS=2; flang -fopenmp snefe018_2.f90; ./a.out
 1 : a =  0 , b =  1025
 1 : a =  145721536 , b =  0
 2 : a =  1 , b = 2
$
```

```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp snefe018_2.f90; ./a.out
 1 : a =            1 , b =            2
 1 : a = 1 , b =            2
 2 : a =            1 , b = 2
$
```

```
$ export OMP_NUM_THREADS=2; ifx -qopenmp snefe018_2.f90; ./a.out
 1 : a =            1 , b =            2
 1 : a =            1 , b =            2
 2 : a =            1 , b = 2
$
```

snefe018_21.f90:
```fortran
program main
  integer a, b
 common /com/ a,b
  a=1
  b=2
!$omp parallel firstprivate(/com/)
 write(6,*) "1 : a = ", a, ", b = ", b
! !$omp parallel private(/com/)
! !$omp end parallel

!$omp end parallel
  write(6,*) "2 : a = ", a, ", b = ", b
end program main
```

```
$ export OMP_NUM_THREADS=2; flang -fopenmp snefe018_21.f90; ./a.out
 1 : a =  1 , b =  2
 1 : a =  1 , b = 2
 2 : a =  1 , b =  2
$
```


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to