https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91416

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This sort of problem, accidentally collecting live data, is typically fixed by
adding
++function_depth;
// whatever
--function_depth;

Here we're in cp_parser_late_parsing_for_member, which calls
start_preparsed_function (++function_depth) and then actually parses the body
using cp_parser_function_definition_after_declarator.

cp_parser_function_definition_after_declarator does

28077   /* Finish the function.  */
28078   fn = finish_function (inline_p);
28079   /* Generate code for it, if necessary.  */
28080   expand_or_defer_fn (fn);

and finish_function does --function_depth.  Then the call to expand_or_defer_fn
triggers calling ggc_collect.

This is similar to PR c++/88180.

Reply via email to