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

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #17 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Jerry DeLisle from comment #16)
> Is anyone working on this one?
Not before your comment. ;-)

Using Tobias' analysis in comment #14, there is an "obvious" fix, augmenting
the reference count of the symbols present in the vector (untested):

Index: symbol.c
===================================================================
--- symbol.c    (révision 220514)
+++ symbol.c    (copie de travail)
@@ -3634,17 +3634,25 @@ do_traverse_symtree (gfc_symtree *st, void (*st_fu
     {
       /* Clear marks.  */
       for (i = 0; i < nodes; i++)
-    st_vec[i]->n.sym->mark = 0;
+    {
+      st_vec[i]->n.sym->mark = 0;
+      st_vec[i]->n.sym->refs++;
+    }
       for (i = 0; i < nodes; i++)
-    if (!st_vec[i]->n.sym->mark)
+    if (!st_vec[i]->n.sym->mark && st_vec[i]->n.sym->refs > 1)
       {
         (*sym_func) (st_vec[i]->n.sym);
         st_vec[i]->n.sym->mark = 1;
       }
+
+      for (i = 0; i < nodes; i++)
+    gfc_release_symbol (st_vec[i]->n.sym);
      }
    else
       for (i = 0; i < nodes; i++)
     (*st_func) (st_vec[i]);
+
+   free (st_vec);
 }

Reply via email to