[Bug c++/122785] [Reflection] -freflection and 'import std;' causes 'recursive lazy load' when 'std' module entity used

nshead at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jan 16 03:43:54 GMT 2026


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122785

--- Comment #4 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Somewhat minimised:

  // a.h
  struct S {
    friend S foo();
    S bar(int);
  };
  inline S s;
  template <typename T> decltype(s.bar(T{})) foo(T);

  // b.cpp
  import "a.h";

$ g++ -fmodules -freflection -S a.h b.cpp
b.cpp:2:9: error: recursive lazy load
    2 | using ::S;
      |         ^
b.cpp:2:9: fatal error: failed to load pendings for ‘::S’
compilation terminated.

What happens here is that the friend declaration forces all of these entities
into the same depset, and it so happens we don't have a complete definition of
'struct ::S' yet before we start reading the definition of '::s'.


More information about the Gcc-bugs mailing list