https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57284
Gerhard Steinmetz <gerhard.steinmetz.fort...@t-online.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gerhard.steinmetz.fortran@t | |-online.de --- Comment #7 from Gerhard Steinmetz <gerhard.steinmetz.fort...@t-online.de> --- Compiles if "size" is replaced with synonym "product(shape)". $ cat z5.f90 module m type t end type contains function foo(a, b) result(add) class(t), intent(in) :: a(:) class(t), intent(in) :: b(product(shape(a))) type(t) :: add(product(shape(a))) end function end module program p use m end program $ gfortran-6 -g -O0 -fcheck=all z5.f90 $ cat z6.f90 module m type t end type contains function foo(a, b) result(add) class(*), intent(in) :: a(:) class(*), intent(in) :: b(product(shape(a))) type(t) :: add(product(shape(a))) end function end module program p use m end program $ gfortran-6 -g -O0 -fcheck=all z6.f90 Remark: This workaround may or may not work for production codes, it depends.