From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 91D52385781F; Wed, 9 Sep 2020 06:57:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91D52385781F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1599634653; bh=c6835/Z3JPVWMySxANhby6ZlgyCgsZ6Do3uzmIzIcjo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Vzeh5cp2nXIKVfkavZ7xbtfmlWQLadOaS8DnUa1pUFxs3XAFR444RN5lHrmGIl49Q /xukojFwHFDaF5rDAQirR+M49tZj54pUDCh25owGi6L8xo7jzFtmS+HTzWGBqbMfgy HmCwferJQw7WQxK/D+Fj1Tq1vcsxsb8eHzs55rrA= From: "markeggleston at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring Date: Wed, 09 Sep 2020 06:57:33 +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: 4.8.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: markeggleston at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: markeggleston 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: Wed, 09 Sep 2020 06:57:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53298 --- Comment #14 from markeggleston at gcc dot gnu.org --- The test case in comment 7 proved trickier to track down. The ICE occurs in this code: /* Components can correspond to fields of different containing types, as components are created without context, whereas a concrete use of a component has the type of decl as context. So, if the type doesn't match, we search the corresponding FIELD_DECL in the parent type. To not waste too much time we cache this result in norestrict_decl. On the other hand, if the context is a UNION or a MAP (a RECORD_TYPE within a UNION_TYPE) always use the given FIELD_DECL. */ if (context !=3D TREE_TYPE (decl) && !( TREE_CODE (TREE_TYPE (field)) =3D=3D UNION_TYPE /* Field is u= nion */ || TREE_CODE (context) =3D=3D UNION_TYPE)) /* Field is map */ { tree f2 =3D c->norestrict_decl; if (!f2 || DECL_FIELD_CONTEXT (f2) !=3D TREE_TYPE (decl)) =3D=3D> for (f2 =3D TYPE_FIELDS (TREE_TYPE (decl)); f2; f2 =3D DECL_CHA= IN (f2)) if (TREE_CODE (f2) =3D=3D FIELD_DECL && DECL_NAME (f2) =3D=3D DECL_NAME (field)) break; gcc_assert (f2); c->norestrict_decl =3D f2; field =3D f2; } The ICE occurs at the line marked with =3D=3D>, the assignment f2 =3D TYPE_= FIELDS (TREE_TYPE (decl)) hides a call to a routine that returns a null pointer wh= ich is then used causing the ICE. I speculated that the code dealing with f2 should not have been executed. I noted that in the comments "On the other hand, if the context is a UNION or= a MAP (a RECORD_TYPE within a UNION_TYPE) always use the given FIELD_DECL." = This does not match the code that follows. The following change: trans-expr.c @@ -2474,8 +2474,8 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref) RECORD_TYPE within a UNION_TYPE) always use the given FIELD_DECL. */ if (context !=3D TREE_TYPE (decl) - && !( TREE_CODE (TREE_TYPE (field)) =3D=3D UNION_TYPE /* Field is = union */ - || TREE_CODE (context) =3D=3D UNION_TYPE)) /* Field is = map */ + && ( TREE_CODE (context) =3D=3D UNION_TYPE /* Field is union */ + || TREE_CODE (context) =3D=3D MAP_TYPE)) /* Field is map */ { tree f2 =3D c->norestrict_decl; if (!f2 || DECL_FIELD_CONTEXT (f2) !=3D TREE_TYPE (decl)) matches the comment and also fixes the ICE for the test case in comment 7. make -j 8 check-fortran was looking good until test case failures were repo= rted for: gfortran.dg/finalize_35.f90 gfortran.dg/finalize_36.f90=