https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83865

            Bug ID: 83865
           Summary: ICE in wide_int_to_tree_1, at tree.c:1567
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gs...@t-online.de
  Target Milestone: ---

Gives an ICE with releases 6, 7, 8 :


$ cat z1.f90
program p
   character(:), allocatable :: z(:)
   allocate (z, source=[''])
end


$ gfortran-8-20180114 -c z1.f90
z1.f90:3:0:

    allocate (z, source=[''])

internal compiler error: in wide_int_to_tree_1, at tree.c:1567
0xdd23c3 wide_int_to_tree_1
        ../../gcc/tree.c:1567
0xdd293b wide_int_to_tree(tree_node*, poly_int<1u,
generic_wide_int<wide_int_ref_storage<false, true> > > const&)
        ../../gcc/tree.c:1692
0xdd293b build_int_cst(tree_node*, poly_int<1u, long>)
        ../../gcc/tree.c:1360
0x7494ae gfc_allocate_allocatable(stmtblock_t*, tree_node*, tree_node*,
tree_node*, tree_node*, tree_node*, tree_node*, tree_node*, gfc_expr*, int)
        ../../gcc/fortran/trans.c:801
0x7b604d gfc_trans_allocate(gfc_code*)
        ../../gcc/fortran/trans-stmt.c:6268
0x747a27 trans_code
        ../../gcc/fortran/trans.c:1980
0x76eb79 gfc_generate_function_code(gfc_namespace*)
        ../../gcc/fortran/trans-decl.c:6451
0x6fe980 translate_all_program_units
        ../../gcc/fortran/parse.c:6103
0x6fe980 gfc_parse_file()
        ../../gcc/fortran/parse.c:6306
0x744e5f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.c:204

---

Version 5 gives :

$ gfortran-5 -c z1.f90
z1.f90:3:13:

    allocate (z, source=[''])
             1
Error: Array specification required in ALLOCATE statement at (1)

---

Works with string length > 0 :

$ cat z2.f90
program p
   character(:), allocatable :: z(:)
   allocate (z, source=['a'])
   print *, z
end

$ gfortran-8-20180114 z2.f90 -static-libgfortran
$ a.out
 a
$

Reply via email to