pt.c (deduction_tsubst_fntype): Don't free the tinst entry if a pending_template...
authorJason Merrill <jason@redhat.com>
Wed, 8 Jun 2011 13:08:45 +0000 (09:08 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 8 Jun 2011 13:08:45 +0000 (09:08 -0400)
* pt.c (deduction_tsubst_fntype): Don't free the tinst entry
if a pending_template entry is pointing at it.

From-SVN: r174807

gcc/cp/ChangeLog
gcc/cp/pt.c

index 5b47f21d2622313f4f473149032fcdcf4ae3cf32..eb6dde0072aab5d28d609e4fd639425322be37d0 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-08  Jason Merrill  <jason@redhat.com>
+
+       PR c++/49322
+       * pt.c (deduction_tsubst_fntype): Don't free the tinst entry
+       if a pending_template entry is pointing at it.
+
 2011-06-07  Jason Merrill  <jason@redhat.com>
 
        PR c++/48969
index f93fa7fd6cc1afa9eeec8f7cad3a33c1405bda73..61ca31c9eccddd6d5e193f27d83d39a740ac61f7 100644 (file)
@@ -13611,6 +13611,7 @@ deduction_tsubst_fntype (tree fn, tree targs)
   static bool excessive_deduction_depth;
   static int deduction_depth;
   location_t save_loc = input_location;
+  struct pending_template *old_last_pend = last_pending_template;
 
   tree fntype = TREE_TYPE (fn);
   tree tinst;
@@ -13644,7 +13645,9 @@ deduction_tsubst_fntype (tree fn, tree targs)
     }
 
   pop_tinst_level ();
-  ggc_free (tinst);
+  /* We can't free this if a pending_template entry is pointing at it.  */
+  if (last_pending_template == old_last_pend)
+    ggc_free (tinst);
   return r;
 }