This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
- From: "vehre at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 20 Mar 2015 11:58:45 +0000
- Subject: [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
- Auto-submitted: auto-generated
- References: <bug-61275-4 at http dot gcc dot gnu dot org/bugzilla/>
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.