From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F04803858428; Sat, 2 Oct 2021 19:39:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F04803858428 From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/102521] ICE in gfc_conv_array_initializer, at fortran/trans-array.c:6240 Date: Sat, 02 Oct 2021 19:39:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Oct 2021 19:39:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102521 --- Comment #4 from anlauf at gcc dot gnu.org --- Tentative patch: diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index b3c65b7175b..cebc59e4ab5 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -2228,12 +2228,15 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus) gfc_expr *array; int n; if (sym->attr.flavor =3D=3D FL_PARAMETER - && init->expr_type =3D=3D EXPR_CONSTANT - && spec_size (sym->as, &size) - && mpz_cmp_si (size, 0) > 0) + && (init->expr_type =3D=3D EXPR_CONSTANT + || init->expr_type =3D=3D EXPR_STRUCTURE) + && spec_size (sym->as, &size) + && mpz_cmp_si (size, 0) > 0) { array =3D gfc_get_array_expr (init->ts.type, init->ts.kind, &init->where); + if (init->ts.type =3D=3D BT_DERIVED) + array->ts.u.derived =3D init->ts.u.derived; for (n =3D 0; n < (int)mpz_get_si (size); n++) gfc_constructor_append_expr (&array->value.constructor, n =3D=3D 0=