From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 38A8A385843D; Wed, 16 Feb 2022 20:10:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38A8A385843D From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/104573] ICE in resolve_structure_cons, at fortran/resolve.cc:1299 Date: Wed, 16 Feb 2022 20:10:34 +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-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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: Wed, 16 Feb 2022 20:10:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104573 anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org --- Comment #2 from anlauf at gcc dot gnu.org --- (In reply to kargl from comment #1) > Only want to access the components of a derived type if we have an actual > derived type. I was wondering if we also need to allow BT_CLASS. So something like the following might also work: diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 266e41e25b1..2fa1acdbd6d 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -1288,15 +1288,17 @@ resolve_structure_cons (gfc_expr *expr, int init) } } - cons =3D gfc_constructor_first (expr->value.constructor); - /* A constructor may have references if it is the result of substituting= a parameter variable. In this case we just pull out the component we want. */ if (expr->ref) comp =3D expr->ref->u.c.sym->components; - else + else if (expr->ts.u.derived) comp =3D expr->ts.u.derived->components; + else + return false; + + cons =3D gfc_constructor_first (expr->value.constructor); for (; comp && cons; comp =3D comp->next, cons =3D gfc_constructor_next = (cons)) {=