http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50659

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011-10-07
     Ever Confirmed|0                           |1

--- Comment #4 from janus at gcc dot gnu.org 2011-10-07 20:36:34 UTC ---
I'm still not completely sure if the test case is valid or not. I could not
find anything in the standard which forbids it, so I'm assuming it is valid for
now.

In any case, here is a draft patch which fixes the ICE:

Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c    (revision 179659)
+++ gcc/fortran/expr.c    (working copy)
@@ -4146,15 +4147,14 @@ replace_symbol (gfc_expr *expr, gfc_symbol *sym, i
        && !gfc_is_intrinsic (expr->symtree->n.sym, 0, expr->where)))
       && expr->symtree->n.sym->ns == sym->ts.interface->formal_ns)
     {
-      gfc_symtree *stree;
-      gfc_namespace *ns = sym->formal_ns;
-      /* Don't use gfc_get_symtree as we prefer to fail badly if we don't find
-     the symtree rather than create a new one (and probably fail later).  */
-      stree = gfc_find_symtree (ns ? ns->sym_root : gfc_current_ns->sym_root,
-                      expr->symtree->n.sym->name);
-      gcc_assert (stree);
-      stree->n.sym->attr = expr->symtree->n.sym->attr;
-      expr->symtree = stree;
+      gfc_symtree *root = sym->formal_ns ? sym->formal_ns->sym_root
+                     : gfc_current_ns->sym_root;
+      gfc_symtree *stree = gfc_find_symtree (root,
expr->symtree->n.sym->name);
+      if (stree)
+    {
+      stree->n.sym->attr = expr->symtree->n.sym->attr;
+      expr->symtree = stree;
+    }
     }
   return false;
 }

Reply via email to