Issue |
151895
|
Summary |
[Flang][OpenMP] Incorrect execution result when assumed-shape array is allocated and defined in parallel construct with private clause
|
Labels |
flang:openmp
|
Assignees |
|
Reporter |
ohno-fj
|
```
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
$
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs