https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122785
Bug ID: 122785
Summary: [Reflection] -freflection and 'import std;' causes
'recursive lazy load' when 'std' module entity used
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: sebastian.jude at st dot ovgu.de
Target Milestone: ---
Created attachment 62866
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62866&action=edit
-v output of compiler separately to reduce noise in report
given:
// test.cpp
import std;
auto main() -> int {
// Using a non-template entity from std module works fine.
// std::exception e;
// Simple type trait causes the error.
// auto x = std::is_integral_v<int>;
// So does a function.
// auto m = std::make_unique<int>()
// And any other templated entity I tried -> only occurs with templates?
std::vector<int> v;
}
then:
❯ x86_64-linux-gnu-g++ -std=c++26 -fmodules -freflection -fsearch-include-path
bits/std.cc test.cpp
./test.cpp: In function 'int main()':
./test.cpp:14:10: error: recursive lazy load
14 | std::vector<int> v;
| ^~~~~~
./test.cpp:14:10: fatal error: failed to load pendings for
'std::in_place_index_t'
compilation terminated.
(for full output with '-v' see attached output.txt)
The compiler used is a freshly built HEAD revision (commit 0fa5a39cc51) from
git://gcc.gnu.org/git/gcc.git which has the C++26 Reflection patch applied
(https://gcc.gnu.org/pipermail/gcc-patches/2025-November/700733.html) plus
commit fe735badc5 "Tweaks from libstdc++-v3 reflection patch review." of the
reflection branch in https://forge.sourceware.org/marek/gcc.git.
The problem also reproduces with the Compiler Explorer version:
https://godbolt.org/z/cx3zMxv3o
Note that no reflection or anything from std::meta is used. The error does not
occur when the -freflection flag is removed and appears only to manifest when a
templated entity is used (just a hunch from what I tired so far).
I followed the Reflection development for a while and occasionally experimented
with various versions. The last commit I compiled which did not exhibit this
behavior was this:
https://forge.sourceware.org/marek/gcc/commit/b34366f63db746adfaa0027eab3d2f506add8e12
So it was probably caused by a change after this commit. Not sure if it is
relevant, but integration of std::meta into the "std" module happened after
that. At the time I did use "import std;" and entities from that module, but
still had to use #include <meta> when experimenting with reflection.
If its of any use: This bug mentions a similar error:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116382
(I did not attach preprocessed files, the one for the main program is virtually
empty when using modules and the one for the 'std' module exceeds attachment
limits)