public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-99798-4-l2pArvfro2@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99798-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99798

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 ready
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 == 0);

  parent reply	other threads:[~2023-05-28  5:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-27 15:59 [Bug fortran/99798] New: " dominiq at lps dot ens.fr
2021-03-27 20:00 ` [Bug fortran/99798] " anlauf at gcc dot gnu.org
2023-05-28  5:11 ` kargl at gcc dot gnu.org [this message]
2023-07-11 14:56 ` mikael at gcc dot gnu.org
2024-05-11 11:27 ` mikael at gcc dot gnu.org
2024-05-20 20:44 ` cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-99798-4-l2pArvfro2@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).