Just curious, is there any reason why you can’t simply use a function?
module bugmod
implicit none
type value_t
end type
type(value_t), target :: foo
contains
function fetch_ptr() result(ptr)
class(value_t), pointer :: ptr
ptr => foo
end function
end module
program test
use bugmod
associate(tmp => fetch_ptr()) ! (bug?!)
print *, associated(tmp,foo)
end associate
end program