<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115672>115672</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][OpenMP] No error checking when allocatable variable is dynamically generated in non-parallel section and then dynamically generated again in parallel section
</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(74b56c7eb807e2ba54bd7a2bcfda5d0bceff1c0c)/AArch64
```
This program checks for error detection.
When `allocatable variable` is dynamically generated in `non-parallel section` and then dynamically generated again in `parallel section`, no error is detected at runtime.
When it is dynamically generated again in `non-parallel section`, a run-time error occurs (`Aborted (core dumped)`).
The following are the test program, Flang-new, Gfortran and ifx compilation/execution result.
snggu805_2.f90:
```fortran
module m1
type y2
integer,dimension(3)::x21=21
integer,dimension(3)::x23=23
end type y2
type y3
integer,dimension(3)::x31=31
type(y2),allocatable:: x32
integer,dimension(3)::x33=33
end type y3
end module m1
subroutine s4
use m1
type(y3),allocatable::v(:)
allocate(v(1))
allocate(v(1)%x32)
!$omp parallel private(v)
if (.not.allocated(v)) print *,1001
allocate(v(1)%x32)
!$omp end parallel
end subroutine s4
program main
call s4
print *,'pass'
end program main
```
```
$ export OMP_NUM_THREADS=2; flang-new -fopenmp snggu805_2.f90; ./a.out
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
pass
$
```
```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp snggu805_2.f90; ./a.out
At line 20 of file snggu805_2.f90
Fortran runtime error: Attempting to allocate already allocated variable 'v'
Error termination. Backtrace:
Program aborted. Backtrace:
#0 0x40002774a917 in ???
#0 0x40002774a917 in ???
#1 0x40002774b5f3 in ???
#1 0x40002774b58b in ???
#2 0x40002774b9af in ???
#2 0x40002774b9b3 in ???
#3 0x40182f in ???
#3 0x40182f in ???
#4 0x400027a5fbf3 in ???
#4 0x400027a59bcb in ???
#5 0x4014d7 in ???
#5 0x400027a762db in ???
#6 0x4015a7 in ???
#6 0x400027a762db in ???
#7 0x401633 in ???
#7 0x400027a762db in ???
#8 0x400027b54383 in ???
#8 0x400027a762db in ???
#9 0x400b3b in ???
#9 0x400027a762db in ???
#10 0x400027a762db in ???
#11 0x400027a762db in ???
#12 0x400027a762db in ???
#13 0x400027a762db in ???
#14 0x400027a762db in ???
#15 0x400027a762db in ???
#16 0x400027a762db in ???
#17 0x400027a762db in ???
#18 0x400027a762db in ???
#19 0x400027a762db in ???
#20 0x400027a762db in ???
#21 0x400027a762db in ???
#22 0x400027a762db in ???
#23 0x400027a762db in ???
#24 0x400027a762db in ???
#25 0x400027a762db in ???
#26 0x400027a762db in ???
#27 0x400027a762db in ???
#28 0x400027a762db in ???
$
```
```
$ export OMP_NUM_THREADS=2; ifx -qopenmp snggu805_2.f90; ./a.out
forrtl: severe (151): allocatable array is already allocated
forrtl: severe (151): allocatable array is already allocated
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysV1uPm7oW_jXOixVkL0MgD3lgZppzXnrROd27j5UBQ9wam23MzOTfb5lLJjMNrStVigiYb33ryrIX73vZaCEOKLlDycOGD-5k7MGctNnW3zaFqc4HtCPzjzwgkv8tbC-NxqbGteK62WrxhBHLMZCIRARBlsZFsitTUWQkFVDwJC6qlENR1hVPKlKUoq5pSUoEewTHPLflaRdP5G90TdfPJ9njzprG8haXJ1F-73FtLBbWGosr4UTppNERxhP-y0lojHaEK2VK7nihBH7kVvobtCNY9rg6a97Kkit1xo3QwnInKixHMW30tuOWKyUU7iduL8Z1hZ2nvi3MGy71THFDHME91ma22Vswmu3lHLaDdrIV0bX90q3bea1qxVqvjnvirWee1ZqyHGyPEWRoR_LCWE-GICuNFbga2k5UPideeh-9zoDAtVHKPEndYG6FDwR2ondLXry-41IO_uE_tbHOcj2GTdbPuDRtJxUf7YOj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