[Bug fortran/68155] ICE on initializing character array in type (len_lhs <> len_rhs)

gerhard.steinmetz.fortran@t-online.de gcc-bugzilla@gcc.gnu.org
Mon Dec 5 17:15:00 GMT 2016


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

Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|5.2.1                       |7.0

--- Comment #6 from Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> ---
Valid code :

$ cat zz1.f90
program p
   character(3) :: c1(2) = '' // ['b', 'c']
   character(3) :: c2(2) = 'a' // ['b', 'c']
   character(3) :: c3(2) = 'ax' // ['b', 'c']
   character(3) :: c4(2) = 'axy' // ['b', 'c']
   print *, size(c1), len(c1), c1
   print *, size(c2), len(c2), c2
   print *, size(c3), len(c3), c3
   print *, size(c4), len(c4), c4
end

$ gfortran-7-20161204 zz1.f90
$ a.out
           2           3 b  c
           2           3 ab ac
           2           3 axbaxc
           2           3 axyaxy

---


Similar, embedded in a type :

$ cat zz2.f90
program p
   type t
      character(3) :: c1(2) = '' // ['b', 'c']
      character(3) :: c2(2) = 'a' // ['b', 'c']
      character(3) :: c3(2) = 'ax' // ['b', 'c']
      character(3) :: c4(2) = 'axy' // ['b', 'c']
   end type
   type(t) :: z
   print *, size(z%c1), len(z%c1), z%c1
   print *, size(z%c2), len(z%c2), z%c2
   print *, size(z%c3), len(z%c3), z%c3
   print *, size(z%c4), len(z%c4), z%c4
end

$ gfortran-7-20161204 zz2.f90
zz2.f90:13:0:

 end

internal compiler error: in output_constructor_regular_field, at varasm.c:5017
0xf3fcc4 output_constructor_regular_field
        ../../gcc/varasm.c:5017
0xf3fcc4 output_constructor
        ../../gcc/varasm.c:5325
0xf3e7c1 output_constant
        ../../gcc/varasm.c:4702
0xf3e7c1 output_constructor_regular_field
        ../../gcc/varasm.c:5055
0xf3e7c1 output_constructor
        ../../gcc/varasm.c:5325
0xf40064 output_constant
        ../../gcc/varasm.c:4702
0xf40064 assemble_variable_contents
        ../../gcc/varasm.c:2083
0xf479c9 assemble_variable(tree_node*, int, int, int)
        ../../gcc/varasm.c:2259
0xf4d1e8 varpool_node::assemble_decl()
        ../../gcc/varpool.c:588
0x85501b output_in_order
        ../../gcc/cgraphunit.c:2248
0x8553ed symbol_table::compile()
        ../../gcc/cgraphunit.c:2488
0x857ea2 symbol_table::compile()
        ../../gcc/cgraphunit.c:2558
0x857ea2 symbol_table::finalize_compilation_unit()
        ../../gcc/cgraphunit.c:2584


More information about the Gcc-bugs mailing list