This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]