Is this standard conforming, both gfortran and ifx compile it, so it should be. But who ever knows with pointers…
module tst_mod
implicit none
type pippo
integer :: z
end type
type,extends(pippo) :: minnie
real :: x
end type
contains
subroutine look(p)
class(pippo),target :: p
type(minnie), pointer :: p_ptr
select type (a => p)
type is (minnie)
p_ptr => a
class default
error stop
end select
p_ptr%x = 45.0
end subroutine
end module
That will be handful as with many passed objects one don’t have to nest one select type inside another.
I’m not sure which aspect of this code you’re questioning, but it looks valid to me. In this example, p is the selector and a the associating entity. The standard (F2023 here) says (11.1.3.3 Other attributes of associate names):
The associating entity does not have the ALLOCATABLE or POINTER attributes; it has the TARGET attribute if and only if the selector is a variable and has either the TARGET or POINTER attribute.
Since p has the TARGET attribute, so does a, and that makes it valid as the target in a pointer assignment.