https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124953
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-16 branch has been updated by Patrick Palka <[email protected]>: https://gcc.gnu.org/g:e1276252881274c04e3dbf422ef603679e793f67 commit r16-8840-ge1276252881274c04e3dbf422ef603679e793f67 Author: Patrick Palka <[email protected]> Date: Mon Apr 27 17:52:03 2026 -0400 c++/modules: defer completion of streamed-in cNTTPs [PR124953] Here we hit lazy loading recursion when streaming in the cNTTP object wrap<Storage>{}, via get_template_parm_object -> cp_finish_decl -> ensure_literal_type_for_constexpr_object -> complete_type, apparently the class definition of wrap<Storage> hasn't been streamed in yet. If we disable that literal type check for NTTP objects, we still hit recursion, from layout_var_decl. It seems prudent to defer calling cp_finish_decl for NTTP objects until after lazy loading has completed like we do for expand_or_defer_fn and cdtors. This patch arranges that, as a follow-up to the some previous NTTP object streaming fixes r15-3031 and r16-318. PR c++/124953 gcc/cp/ChangeLog: * module.cc (trees_in::tree_node) <tt_nttp_var>: Push the result of get_template_parm_object to post_load_decls. (post_load_processing): Call cp_finish_decl on any not yet completed NTTP objects. * pt.cc (get_template_parm_object): Don't call cp_finish_decl when !check_init. gcc/testsuite/ChangeLog: * g++.dg/modules/tpl-nttp-3_a.H: New test. * g++.dg/modules/tpl-nttp-3_b.C: New test. Reviewed-by: Jason Merrill <[email protected]> (cherry picked from commit d566a83a79424ef6444960ae79bab90ed76ad8e2)
