I discovered that gfortran gives a compilation error while trying to use an automatic object of a parameterized derived type. For example, trying to compile
module vector
type :: vec(dimen)
integer,len :: dimen
real :: e(dimen)
end type vec
contains
function double(a)
type(vec(*)),intent(in) :: a
type(vec(a%dimen)) :: double
double%e = 2.*a%e
end function double
end module vector
results into the following error:
Error: The AUTOMATIC object ‘double’ at (1) must not have the SAVE attribute or be a variable declared in the main program, a module or a submodule(F08/C513)
I cannot make sense out of it. Where is the save attribute? Also, ifort compiles without complain. This convinced me that this must be a compiler bug. I tried f18, just as a check, before going for bugzilla. And lo! it spits the same error verbatim. Now, I’m confused. Am I missing something in the standard? How come two different compilers are giving exactly same error message?