From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E57F63858D3C; Sun, 28 May 2023 05:11:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E57F63858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685250710; bh=eR1RtQjh84weJESgv2XdMWdp+7upikhgECj7giS68Eg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MtIMhxGURHq5RKdmX2ik5cIor4Nm4tYXQdw1rdQKh5N8ZFaqZzD++gzDQWM3F443a XF5cNsqOlX38ttzcHEpgB9TvMT/D4j+d92g+HnN1aMlmmcuMkWfJ/0rf0XDxaDmFpe vtthWJI8grV29GOTonAvyfcFTxpMjWXPmfwSD5ak= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/99798] ICE when compiling a variant of pr87907 Date: Sun, 28 May 2023 05:11:50 +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: kargl 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 priority 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=3D99798 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org Priority|P3 |P4 --- Comment #1 from kargl at gcc dot gnu.org --- This patch prevents the ICE. Instead of asserting that the namespace is re= ady to be freed, simply return if the reference count appears to be bogus and gfortran has already issued one or more errors. diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc index 221165d6dac..8e48cbba2ca 100644 --- a/gcc/fortran/symbol.cc +++ b/gcc/fortran/symbol.cc @@ -27,7 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "parse.h" #include "match.h" #include "constructor.h" - +#include "diagnostic.h" /* Access to errorcount in gfc_free_namespace ().= */ /* Strings for all symbol attributes. We use these for dumping the parse tree, in error messages, and also when reading and writing @@ -4043,7 +4043,7 @@ gfc_free_namespace (gfc_namespace *&ns) return; ns->refs--; - if (ns->refs > 0) + if (ns->refs > 0 || (ns->refs < 0 && errorcount > 0)) return; gcc_assert (ns->refs =3D=3D 0);=