https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92586
--- Comment #6 from G. Steinmetz <gs...@t-online.de> --- Compiles these slightly modified cases : $ cat z2.f90 # no allocatable a program p type t integer :: a end type type t2 type(t) :: b end type type t3 type(t2) :: c end type contains function g(x) class(t2) :: x type(t) :: g(2) end function f(x) class(t3) :: x type(t) :: f(2) f = g(x%c) end end $ cat z3.f90 # scalar functions g, f program p type t integer, allocatable :: a end type type t2 type(t) :: b end type type t3 type(t2) :: c end type contains function g(x) class(t2) :: x type(t) :: g end function f(x) class(t3) :: x type(t) :: f f = g(x%c) end end