Issue |
145256
|
Summary |
[flang] runtime crash when optional arguments are passed as arguments to another function
|
Labels |
flang
|
Assignees |
|
Reporter |
shivaramaarao
|
consider the following program
```
module optional_class_module
implicit none
type :: MyType
integer :: value
contains
procedure :: show
end type MyType
contains
! Type-bound procedure for MyType
subroutine show(this)
class(MyType), intent(inout) :: this
print *, "MyType value is:", this%value
end subroutine show
subroutine process_data_2(obj)
class(MyType), intent(inout) :: obj
call process_data_3(obj)
end subroutine
subroutine process_data_3(obj)
class(MyType), intent(inout) :: obj
end subroutine
subroutine process_data(obj)
class(MyType), intent(inout), optional :: obj
if (present(obj)) then
select type(obj)
type is (MyType)
print *, "Optional object is present."
call obj%show()
class default
print *, "Unknown type passed."
end select
else
print *, "No object was passed."
end if
call process_data_2(obj)
end subroutine process_data
end module optional_class_module
program test_optional_class
use optional_class_module
implicit none
type(MyType) :: a
a%value = 42
print *, "--- Call with object ---"
call process_data(a)
print *, "--- Call without object ---"
call process_data()
end program test_optional_class
```
The program crashes at runtime with flang. It passes with other compilers
```
--- Call with object ---
Optional object is present.
MyType value is: 42
--- Call without object ---
No object was passed.
Segmentation fault (core dumped)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs