On Wed, Dec 11, 2013 at 11:51:55AM -0500, Jason Merrill wrote: > It's only safe to free the targs if they weren't used to instantiate > any templates, so I lean toward option #1. Did you test this with > strict gc?
Ok, after IRC discussion and another bootstrap/regtest I've installed this variant instead: 2013-12-12 Jakub Jelinek <ja...@redhat.com> PR c++/58627 * call.c (add_template_candidate_real): Don't call ggc_free on targs. --- gcc/cp/class.c.jj 2013-11-28 08:18:58.000000000 +0100 +++ gcc/cp/class.c 2013-12-11 20:57:40.155059669 +0100 @@ -7475,8 +7475,6 @@ resolve_address_of_overloaded_function ( /* See if there's a match. */ if (same_type_p (target_fn_type, static_fn_type (instantiation))) matches = tree_cons (instantiation, fn, matches); - - ggc_free (targs); } /* Now, remove all but the most specialized of the matches. */ Jakub