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: "antony at cosmologist dot info" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 20 Mar 2015 12:32:13 +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 #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-bugzilla@gcc.gnu.org]
> Sent: 20 March 2015 11:59 AM
> To: antony@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.