Issue |
110441
|
Summary |
[Flang] Execution error when a variable with optional and pointer attributes defined is used as an argument to a subroutine
|
Labels |
flang
|
Assignees |
|
Reporter |
ohno-fj
|
```
Version of flang-new : 20.0.0(2603c8b23be06116bc61bda36fae05b81d906c3f)/AArch64
```
When a variable with `optional` and `pointer` attributes defined is used as an argument to a `subroutine`, a run-time error occurs (`Segmentation fault (core dumped)`).
When `pointer` attribute is changed to `allocatable` attribute, the execution also fails.
When `pointer` and `allocatable` attributes are not specified, the execution succeeds.
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.
F01_12.f90:
```fortran
program main
call sub3()
print*,"Pass"
contains
subroutine sub3(ptr)
integer,optional,pointer :: ptr(:) ! Segmentation fault
! integer,optional,allocatable :: ptr(:) ! Segmentation fault
! integer,optional :: ptr(:) ! OK
call sub(ptr)
end subroutine sub3
subroutine sub(dmy)
integer,optional::dmy(:)
write(6,*) "present(dmy) = ", present(dmy)
end subroutine sub
end program main
```
```
$ flang-new F01_12.f90; ./a.out
Segmentation fault (core dumped)
$
```
```
$ gfortran F01_12.f90; ./a.out
present(dmy) = F
Pass
$
```
```
$ ifort -diag-disable=10448 F01_12.f90; ./a.out
present(dmy) = F
Pass
$
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs