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

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 == 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 == 0);
   gfc_free_symbol (sym);
 }

Reply via email to