https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121401
Bug ID: 121401 Summary: Pointer assignment from polymorphic pointer to non-polymorphic function result doesn't set the vtype Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mikael at gcc dot gnu.org Target Milestone: --- Testcase: program test implicit none type :: t integer :: c end type type, extends(t) :: u integer :: d end type type(u), target :: a(5) class(t), pointer :: p(:) a = [ u(3,5), u(7,11), u(13,17), u(19,23), u(29,31) ] p => f() ! print *, shape(p) if (any(shape(p) /= [5])) error stop 1 ! print *, p%c if (any(p%c /= [ 3,7,13,19,29 ])) error stop 2 contains function f() type(u), pointer :: f(:) f => a end function end program It gives a segmentation fault when executed. The dump of the p => f() pointer assignment is: ... ptrtemp.9.span = 4; f (&ptrtemp.9); p._data = ptrtemp.9; ... So the p._vptr field is never set.