Wrapping source "x" : $ cat z1.f90 program p type t end type class(t), allocatable :: x(:)[:] class(t), allocatable :: z(:) allocate (x(2)[*]) allocate (z, source=(x)) end $ cat z2.f90 program p type t end type class(t), allocatable :: x(:)[:] class(t), allocatable :: z(:) allocate (x(2)[*]) allocate (z, mold=(x)) end $ gfortran-8-20171112 -c z1.f90 -fcoarray=single z1.f90:7:0: allocate (z, source=(x)) internal compiler error: Segmentation fault 0xb61c7f crash_signal ../../gcc/toplev.c:325 0x75b91f vptr_field_get ../../gcc/fortran/trans-expr.c:264 0x75c71d gfc_vptr_size_get(tree_node*) ../../gcc/fortran/trans-expr.c:325 0x79f9fb gfc_trans_allocate(gfc_code*) ../../gcc/fortran/trans-stmt.c:5842 0x731ce7 trans_code ../../gcc/fortran/trans.c:1980 0x75897c gfc_generate_function_code(gfc_namespace*) ../../gcc/fortran/trans-decl.c:6421 0x6ea920 translate_all_program_units ../../gcc/fortran/parse.c:6091 0x6ea920 gfc_parse_file() ../../gcc/fortran/parse.c:6294 0x72f13f gfc_be_parse_file ../../gcc/fortran/f95-lang.c:204
This variant compiles, of course : $ cat z3.f90 program p type t end type class(t), allocatable :: x(:)[:] class(t), allocatable :: z(:) allocate (x(2)[*]) allocate (z, source=x) end
Confirmed from 6.4.0 up to trunk (8.0). If I replace allocate (z, source=(x)) with allocate (z(2), source=(x)) compiling the test gives an ICE also for 4.8, 4.9, and 5.
I need the following on the trunk: Error: non-trivial conversion in 'var_decl' struct array02_t struct array01_character(kind=1) ctmp.3._data = atmp.2; /app/example.f90:2:9: internal compiler error: 'verify_gimple' failed