https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68226
--- Comment #1 from Gerhard Steinmetz <gerhard.steinmetz.fort...@t-online.de> --- As a note, a correct code compiles and works : $ cat z1ok.f90 program p type t integer :: n end type type(t), pointer :: a(:) a => f() print *, a contains function f() result(r) class(t), pointer :: r(:) type(t), target :: b(2) = [t(1), t(2)] r => b end end $ gfortran -g -O0 -Wall -fcheck=all z1ok.f90 $ a.out 1 2