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

--- Comment #3 from anlauf at gcc dot gnu.org ---
The code works if we replace the r.h.s. in the initialization by an array:

program p
  type t
     integer :: n
  end type
! type(t), parameter :: a(4)   = t(1)                            ! ICE
  type(t), parameter :: a(4)   = spread (t(1), dim=1, ncopies=4) ! works
  type(t), parameter :: c(*)   = a
  type(t), parameter :: b(2,2) = reshape(a, [2,2])
  print *, b
end

The code in add_init_expr_to_sym looks fishy.  We might possibly handle the
ICEing code here but don't:

2224          /* Add initializer.  Make sure we keep the ranks sane.  */
2225          if (sym->attr.dimension && init->rank == 0)
2226            {
2227              mpz_t size;
2228              gfc_expr *array;
2229              int n;
2230              if (sym->attr.flavor == FL_PARAMETER
2231                    && init->expr_type == EXPR_CONSTANT
2232                    && spec_size (sym->as, &size)
2233                    && mpz_cmp_si (size, 0) > 0)

(gdb) p init->expr_type
$1 = EXPR_STRUCTURE

Reply via email to