[Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
vehre at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Mar 20 13:51:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
--- Comment #7 from vehre at gcc dot gnu.org ---
First sentence of F2008, 7.1.12 is:
A constant expression is an expression with limitations that make it
suitable for use as a kind type parameter, *initializer*, or named
constant. It is an expression in which each operation is intrinsic,
and each primary is ...
With Type(T) :: TestObj = T(...) the T after the assign becomes an initializer,
which 7.1.12 states only constant expressions are suitable for. In this
constant expression each structure constructor has to adhere to the conditions
of (3):
a structure constructor where each component-spec corresponding to
(a) an allocatable component is a reference to the intrinsic function
NULL,
(b) ...
Now that S is an allocatable component of T. I think this the only valid
expression for that is NULL() as initializer. This is what gfortran does
currently and this is how I interpret the standard.
Btw, cosmomc compiles fine, so it can't be using this specific construct.
More information about the Gcc-bugs
mailing list