https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116382
Bug ID: 116382 Summary: [modules] Importing NTTP of template type causes recursive lazy load Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: nshead at gcc dot gnu.org Reporter: nshead at gcc dot gnu.org Blocks: 103524 Target Milestone: --- Consider: // a.cpp module m:a; template <typename> struct X {}; template <X<int> nttp> struct index {}; template struct index<{}>; // m.cpp export module m; import :a; With 'g++ -fmodules-ts -std=c++20 -S a.cpp m.cpp': m.C:2:11: error: recursive lazy load 2 | import :a; | ^ m.C:2:11: fatal error: failed to load pendings for ‘::X’ compilation terminated. This error occurs even with '-fno-module-lazy'. The root cause seems to be the following logic for streaming in NTTPs in 'trees_in::tree_node': case tt_nttp_var: /* An NTTP object. */ { tree init = tree_node (); tree name = tree_node (); if (!get_overrun ()) { res = get_template_parm_object (init, name); int tag = insert (res); dump (dumper::TREE) && dump ("Created nttp object:%d %N", tag, name); } } break; The call to 'get_template_parm_object' calls 'cp_finish_decl' which eventually ends up performing name lookup on the as-yet unstreamed '::X' when processing the initialiser, resulting in a call to 'lazy_load_pendings' which cannot be done during streaming. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524 [Bug 103524] [meta-bug] modules issue