I’d like to report possible compiler bug. The following code segfaults on call to self%subfunc():
module test_module
implicit none
public
type :: test_type
integer :: val = 0
contains
procedure :: func
procedure :: subfunc
end type
contains
function func(self) result(res)
class(test_type), intent(inout), target :: self
integer, pointer :: res
call self%subfunc()
nullify(res)
end function
subroutine subfunc(self)
class(test_type), intent(in), target :: self
endsubroutine
end module
program test_prog
use test_module
type(test_type) :: var
integer, pointer :: res
res => var%func()
end program
If I change return type to simple integer and replace assignments accordingly it runs fine. Original code compiles and runs on gfortran without errors.