Patchwork C++ PATCH for c++/49322 (libstdc++ testsuite failures)

login
register
mail settings
Submitter Jason Merrill
Date June 8, 2011, 1:11 p.m.
Message ID <4DEF751D.40000@redhat.com>
Download mbox | patch
Permalink /patch/99422/
State New
Headers show

Comments

Jason Merrill - June 8, 2011, 1:11 p.m.
In my last patch I ggc_freed a tree that was used in tinst levels, 
leading to GC corruption when a tinst level is saved in a pending 
template.  This patch avoids that by not freeing if we've allocated a 
pending template.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit c8c28d6fc74a40f62e5a88352a04787931423e41
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Jun 7 23:49:29 2011 -0400

    	* pt.c (deduction_tsubst_fntype): Don't free the tinst entry
    	if a pending_template entry is pointing at it.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f93fa7f..61ca31c 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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;
 }