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

--- Comment #11 from G. Steinmetz <gs...@t-online.de> ---

Well, the ICEs are gone for all posted test cases above.

Assuming that different shapes are not supported as an extension
(aka feature), as such they are not standard-conforming.

F2018 7.5.10 item 2 says
"... expr shall conform in the same way as for a variable
and expr in an intrinsic assignment statement (10.2.1.2).
If necessary, each value of intrinsic type is converted
according to the rules of intrinsic assignment (10.2.1.3)
to a value that agrees in type and type parameters with
the corresponding component of the derived type. For a
nonpointer nonallocatable component, the shape of the
expression shall conform with the shape of the component."


In the following modified example z1.f90 from comment 0
x and z should be flagged with an error :

$ cat z1b.f90
program p
   type t
      integer :: n
      character :: c(2)
   end type
   type(t) :: x = t(1, ['a'])
   type(t) :: y = t(2, ['a', 'b'])
   type(t) :: z = t(3, ['a', 'b', 'c'])
end


---


In the meantime I felt compelled to dig a little further ... 
and unfortunately there are more variants, which fail. 
(also depending on presence/absence of parameter attribute,
prints, compile options)


$ cat za.f90
program p
   type t
      integer :: a(1)
      integer :: b(1)
   end type
   type(t), parameter :: z(2) = t([1,2], [3])
end


$ gfortran-9-20190224 -c za.f90
$ gfortran-9-20190224 -c za.f90 -g
za.f90:7:0:

    7 | end
      |
internal compiler error: in native_encode_initializer, at dwarf2out.c:20274
0x804af8 native_encode_initializer
        ../../gcc/dwarf2out.c:20274
0x804a97 native_encode_initializer
        ../../gcc/dwarf2out.c:20316
0x804ad7 native_encode_initializer
        ../../gcc/dwarf2out.c:20259
0x826d15 tree_add_const_value_attribute
        ../../gcc/dwarf2out.c:20374
#...



$ cat zb.f90
program p
   type t
      integer :: a(1)
      integer :: b(1)
   end type
   type(t), parameter :: z(2) = t([1,2], [3])
   print *, z
end


$ gfortran-9-20190224 -c zb.f90    # -g not necessary
zb.f90:8:0:

    8 | end
      |
internal compiler error: in output_constructor_regular_field, at varasm.c:5207
0xda71d1 output_constructor_regular_field
        ../../gcc/varasm.c:5207
0xda71d1 output_constructor
        ../../gcc/varasm.c:5513
0xda68a5 output_constant
        ../../gcc/varasm.c:4885
0xda68a5 output_constructor_regular_field
        ../../gcc/varasm.c:5246
#...

Reply via email to