https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93922
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The problem as I understand it is that #1 0x0000000000abeb95 in mark_used (decl=<function_decl 0x7fffea955b00 __dt_comp >, complain=3) at ../../gcc/cp/decl2.c:5686 #2 0x0000000000987243 in build_over_call (cand=0x375c910, flags=35, complain=3) at ../../gcc/cp/call.c:9020 #3 0x000000000098c640 in build_new_method_call_1 (instance=<indirect_ref 0x7fffea969c20>, fns=<function_decl 0x7fffea955b00 __dt_comp >, args=0x0, conversion_path=<tree_binfo 0x7fffea93e900>, flags=35, fn_p=0x0, complain=3) at ../../gcc/cp/call.c:10305 #4 0x000000000098cb2e in build_new_method_call (instance=<indirect_ref 0x7fffea969c20>, fns=<baselink 0x7fffea972060>, args=0x0, conversion_path=<tree_binfo 0x7fffea93e900>, flags=35, fn_p=0x0, complain=3) at ../../gcc/cp/call.c:10380 #5 0x000000000098a256 in build_special_member_call (instance=<indirect_ref 0x7fffea969c20>, name=<identifier_node 0x7fffea80e9c0 __dt_comp >, args=0x0, binfo=<tree_binfo 0x7fffea93e900>, flags=35, complain=3) at ../../gcc/cp/call.c:9781 #6 0x0000000000afa23c in build_dtor_call (exp=<indirect_ref 0x7fffea969c20>, dtor_kind=sfk_complete_destructor, flags=35, complain=3) at ../../gcc/cp/init.c:4786 #7 0x0000000000afaaca in build_delete (loc=0, otype=<pointer_type 0x7fffea958150>, addr=<nop_expr 0x7fffea969c00>, auto_delete=sfk_complete_destructor, flags=35, use_global_delete=0, complain=3) at ../../gcc/cp/init.c:4979 #8 0x0000000000a9e585 in cxx_maybe_build_cleanup (decl=<component_ref 0x7fffea972030>, complain=3) at ../../gcc/cp/decl.c:17394 #9 0x0000000000d130b8 in split_nonconstant_init_1 (dest=<mem_ref 0x7fffea963de8>, init=<constructor 0x7fffea947978>, nested=false) at ../../gcc/cp/typeck2.c:714 #10 0x0000000000d1351a in split_nonconstant_init (dest=<mem_ref 0x7fffea963de8>, init=<constructor 0x7fffea947978>) at ../../gcc/cp/typeck2.c:784 happens too late, after pending templates have been instantiated. So, either mark_used or maybe_instantiate_decl needs to not defer if at_eof (or at_eof == 2?), or perhaps better discover that split_nonconstant_init_1 will need to call the descriptor earlier (dunno where exactly, cp_fold or cp_genericize_r?). I think the latter would be better, e.g. with OpenMP implicit declare target discovery I was hoping one could hook somewhere into cgraph in between where the FE already saw all functions and before first functions are gimplified, but if gimplification can result in new functions to be instantiated, genericized and later on gimplified and again and again, this wouldn't be possible.