From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C789E3858299; Tue, 21 Jun 2022 20:47:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C789E3858299 From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/106050] ICE in reject_statement, at fortran/parse.cc:2879 Date: Tue, 21 Jun 2022 20:47:24 +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: 13.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl 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: bug_status everconfirmed cf_reconfirmed_on 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: Tue, 21 Jun 2022 20:47:24 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106050 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2022-06-21 CC| |kargl at gcc dot gnu.org --- Comment #1 from kargl at gcc dot gnu.org --- With torched input, I might expect the symbol table to get sideways. Before asserting the reference count is zero, check if the count is negative and an error message has already been emitted. diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc index 7a80dfd063b..3aa2b9bd962 100644 --- a/gcc/fortran/symbol.cc +++ b/gcc/fortran/symbol.cc @@ -3106,6 +3106,7 @@ gfc_free_symbol (gfc_symbol *&sym) void gfc_release_symbol (gfc_symbol *&sym) { + if (sym =3D=3D NULL) return; @@ -3123,6 +3124,14 @@ gfc_release_symbol (gfc_symbol *&sym) if (sym->refs > 0) return; + if (sym->refs < 0) + { + int ecnt; + gfc_get_errors (NULL, &ecnt); + if (ecnt > 0) + return; + } + gcc_assert (sym->refs =3D=3D 0); gfc_free_symbol (sym); }=