Skip to content

[Flang][OpenMP] No error checking when allocatable variable is dynamically generated in non-parallel section and then dynamically generated again in parallel section #115672

Closed
@ohno-fj

Description

@ohno-fj
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:

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
$

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions