https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
--- Comment #6 from Antony Lewis <antony at cosmologist dot info> --- Not sure about that - 7.1.12 of 2008 is about constants, but in the example the type instance is not a constant? The example is fine in ifort (and used in cosmomc?). Antony > -----Original Message----- > From: vehre at gcc dot gnu.org [mailto:gcc-bugzi...@gcc.gnu.org] > Sent: 20 March 2015 11:59 AM > To: ant...@cosmologist.info > Subject: [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE > component in structure constructor at (1) > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275 > > --- Comment #5 from vehre at gcc dot gnu.org --- > Completely right, the initial test is still not compilable. But this is > because > assigning to an allocatable component in an initializer is not allowed by the > standards: > F2003, 7.1.7 (3) and also in > F2008, 7.1.12 (3). > > So the correct code would be: > > module A > > Type T > character(LEN=:), allocatable :: S > end type > Type(T) :: TestObj = T(NULL()) > > TestObj%S = 'string' > > contains > > end module > > which compiles and runs w/o error. > Standard compliant implementation is tested for in > > gfortran.dg/alloc_comp_init_expr.f03 > > only far allocatable arrays, but that's near enough for char arrays for me. > > -- > You are receiving this mail because: > You reported the bug.