https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77947
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> --- As we do not reclaim B::m_fn2::C::m_fn1 we IMHO shouldn't reclaim its decl_function_context either. In that case we'd generate proper debug info for B::m_fn2::C::m_fn1 which we end up using in the code later on through devirt. Index: gcc/cgraphunit.c =================================================================== --- gcc/cgraphunit.c (revision 241022) +++ gcc/cgraphunit.c (working copy) @@ -1126,6 +1126,13 @@ analyze_functions (bool first_time) = cgraph_node::get_create (DECL_ABSTRACT_ORIGIN (decl)); origin_node->used_as_abstract_origin = true; } + /* Preserve a functions function context node. It will + later be needed to output debug info. */ + if (tree fn = decl_function_context (decl)) + { + cgraph_node *origin_node = cgraph_node::get_create (fn); + enqueue_node (origin_node); + } } else { fixes this bug (and creates proper debug info).