Segfault in type-bound function with pointer return value

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.

$ pgfortran --version

pgfortran 18.4-0 64-bit target on x86-64 Linux -tp nehalem 
PGI Compilers and Tools
Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.

no compiler options were used

Hi Kikht,

I’ve filed TPR #26410 for someone to take a closer look at.

Hi Kikht,

This should be resolved with PGI release 19.1. Leaving a comment here to let you know and in case anyone runs into this issue later on.