https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85001
--- Comment #1 from G. Steinmetz <gs...@t-online.de> --- These two variants compile without any errors : $ cat z2.f90 program p type t end type call s contains real function f(x) class(t) :: x(:) f = 1.0 end subroutine s type(t) :: x(2) real :: z z = f(x) end end $ cat z3.f90 program p type t end type call s contains real function f(x) type(t) :: x dimension :: x(:) f = 1.0 end subroutine s type(t) :: x(2) real :: z z = f(x) end end $ gfortran-8-20180318 -c z2.f90 $ gfortran-8-20180318 -c z3.f90 $