From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 178EB3858401; Thu, 1 Sep 2022 22:44:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 178EB3858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662072296; bh=M8jfvpE/lJC8dyGomGI0HRhiQ7sPjdor25j1dRBn7/U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RWWLOfTE4S6JtrnbNiTn/pDmDcS1R/a74+GilRAtwlzo553GK02H2V85/Sd95w6kZ ZLA8qZJlMMwS8vOsWa5EmTF1jzCBJb5tvPCdl39jWdq4YLbCHxu2LClm/YmElMFVbL YNvMqfBP/B/jjUK0C+Dz/ielLT8U4gFaX1U2l4QE= From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/99349] ICE in match_data_constant, at fortran/decl.c:426 Date: Thu, 01 Sep 2022 22:44:55 +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: 11.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99349 --- Comment #7 from Steve Kargl -= -- On Thu, Sep 01, 2022 at 06:45:25PM +0000, anlauf at gcc dot gnu.org wrote: > > Alternatively, simply catching the NULL pointer dereference by >=20 > diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc > index b6400514731..0f9b2ced4c2 100644 > --- a/gcc/fortran/decl.cc > +++ b/gcc/fortran/decl.cc > @@ -423,7 +423,8 @@ match_data_constant (gfc_expr **result) > data-pointer-initialization compatible (7.5.4.6) with the initial > data target; the data statement object is initially associated > with the target. */ > - if ((*result)->symtree->n.sym->attr.save > + if ((*result)->symtree > + && (*result)->symtree->n.sym->attr.save > && (*result)->symtree->n.sym->attr.target) > return m; > gfc_free_expr (*result); >=20 > also fixes the ICE. It's basically that the error message generated diff= ers > from the one I get with your patch. >=20 > Do you have additional thoughts? >=20 Now, that I've looked at the two patches again. I think I prefer yours or mine. A simple NULL pointer dereference can be committed under the "Obviously correct" rule.=