https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122785
--- Comment #7 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Ah, looks like I missed the last line of b.cpp when I copied... should be
// b.cpp
import "a.h";
using ::S;
or otherwise compile with `-fno-module-lazy` should reproduce as well.
Full backtrace is
#0 error_at (loc=1149952, gmsgid=0x43c0b2c "recursive lazy load") at
../../gcc/gcc/diagnostic-global-context.cc:644
#1 0x000000000124eb42 in recursive_lazy (snum=4294967295) at
../../gcc/gcc/cp/module.cc:16775
#2 0x0000000001262fa1 in lazy_load_pendings (decl=<type_decl 0x7ffff75e4000
S>) at ../../gcc/gcc/cp/module.cc:22689
#3 0x00000000014df53e in complete_type (type=<record_type 0x7ffff75c9d20 S>)
at ../../gcc/gcc/cp/typeck.cc:135
#4 0x0000000001446b96 in consteval_only_p (t=<record_type 0x7ffff75c9d20 S>)
at ../../gcc/gcc/cp/reflect.cc:8079
#5 0x0000000001104b6d in maybe_commonize_var (decl=<var_decl 0x7ffff75e11c8
s>) at ../../gcc/gcc/cp/decl.cc:7302
#6 0x0000000001161217 in tentative_decl_linkage (decl=<var_decl 0x7ffff75e11c8
s>) at ../../gcc/gcc/cp/decl2.cc:3786
#7 0x000000000123da4f in (anonymous namespace)::trees_in::read_var_def
(this=0x7fffffffce20,
decl=<var_decl 0x7ffff75e11c8 s>, maybe_template=<var_decl 0x7ffff75e11c8
s>) at ../../gcc/gcc/cp/module.cc:13282
#8 0x00000000012432ad in (anonymous namespace)::trees_in::read_definition
(this=0x7fffffffce20,
decl=<var_decl 0x7ffff75e11c8 s>) at ../../gcc/gcc/cp/module.cc:14101
#9 0x0000000001252605 in module_state::read_cluster (this=0x7ffff740f708,
snum=1) at ../../gcc/gcc/cp/module.cc:17824
#10 0x000000000125ee39 in module_state::load_section (this=0x7ffff740f708,
snum=1, mslot=0x7ffff740d8f8)
at ../../gcc/gcc/cp/module.cc:21649
#11 0x0000000001262d15 in lazy_load_binding (mod=1, ns=<namespace_decl
0x7ffff741f000 ::>,
id=<identifier_node 0x7ffff75e2d40 S>, mslot=0x7ffff740d8f8) at
../../gcc/gcc/cp/module.cc:22640
#12 0x00000000012842eb in name_lookup::search_namespace_only
(this=0x7fffffffd200,
scope=<namespace_decl 0x7ffff741f000 ::>) at
../../gcc/gcc/cp/name-lookup.cc:935
#13 0x00000000012848b5 in name_lookup::search_namespace (this=0x7fffffffd200,
scope=<namespace_decl 0x7ffff741f000 ::>)
at ../../gcc/gcc/cp/name-lookup.cc:1028
#14 0x0000000001284bcd in name_lookup::search_qualified (this=0x7fffffffd200,
scope=<namespace_decl 0x7ffff741f000 ::>, usings=true) at
../../gcc/gcc/cp/name-lookup.cc:1089
#15 0x00000000012a0e81 in qualified_namespace_lookup (scope=<namespace_decl
0x7ffff741f000 ::>, lookup=0x7fffffffd200)
at ../../gcc/gcc/cp/name-lookup.cc:7590
#16 0x000000000129c0d0 in lookup_using_decl (scope=<namespace_decl
0x7ffff741f000 ::>, lookup=...)
at ../../gcc/gcc/cp/name-lookup.cc:6192
#17 0x000000000129eda5 in finish_nonmember_using_decl (scope=<namespace_decl
0x7ffff741f000 ::>,
name=<identifier_node 0x7ffff75e2d40 S>) at
../../gcc/gcc/cp/name-lookup.cc:6842
Yeah, caching some bits and then checking on them here would work. I've also
been playing around with maybe just streaming the result of 'consteval_type_p'
and then using that to skip calling tentative_decl_linkage as another possible
approach.