I have seen compiler build error (segmentation fault) in libstdc++-v3. It turns out that a vector allocated in gc memory is GCed before the vector is released. The gc call is from a call to synethesize_method from cp_finish_decl.
The following patch fixes the problem. Compiler bootstraps and tested on linux/x86-64. Ok for trunk (or better fix suggested)? thanks, David 2011-11-05 Xinliang David Li <davi...@google.com> * cp/decl.c (cp_finish_decl): Prevent cleanups from being garbage collected before being released. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 181013) +++ cp/decl.c (working copy) @@ -5902,6 +5902,8 @@ value_dependent_init_p (tree init) FLAGS is LOOKUP_ONLYCONVERTING if the = init syntax was used, else 0 if the (init) syntax was used. */ +static GTY (()) VEC(tree,gc) *cleanups_vec; + void cp_finish_decl (tree decl, tree init, bool init_const_expr_p, tree asmspec_tree, int flags) @@ -5914,6 +5916,7 @@ cp_finish_decl (tree decl, tree init, bo bool var_definition_p = false; tree auto_node; + cleanups_vec = cleanups; if (decl == error_mark_node) return; else if (! decl) @@ -6319,6 +6322,7 @@ cp_finish_decl (tree decl, tree init, bo FOR_EACH_VEC_ELT (tree, cleanups, i, t) push_cleanup (decl, t, false); release_tree_vector (cleanups); + cleanups_vec = NULL; if (was_readonly) TREE_READONLY (decl) = 1;