https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127338
Bug ID: 127338
Summary: [modules] recursive lazy load / failed to load
pendings for nested type of imported class template
Product: gcc
Version: 16.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: anthonygaudino45 at gmail dot com
Target Milestone: ---
Created attachment 65565
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65565&action=edit
Self-contained reproducer: lunamini.cppm, ifacey.cppm, implx.cpp --
header-free, no dependencies beyond the compiler
Compiling an implementation unit fails when the interface declares a
static data member typed as a nested type of an imported class template
instantiated on the enclosing class itself.
Reproducer (3 files, no includes, no dependencies beyond the compiler):
lunamini.cppm:
export module lunamini;
export template<class T> struct Luna {
struct Prop {
const char *name;
int (T::*getter)();
int (T::*setter)(int);
};
};
ifacey.cppm:
export module y;
import lunamini;
export struct X {
X() = default;
X(int v);
int value = 0;
static Luna<X>::Prop table[];
};
implx.cpp:
module;
module y;
import lunamini;
X::X(int v) : value(v) {}
Commands (both interfaces build cleanly, even with -Wall -Wextra;
the implementation unit fails):
g++ -std=c++26 -fmodules -Wall -Wextra -fmodule-only -c lunamini.cppm
g++ -std=c++26 -fmodules -Wall -Wextra -fmodule-only -c ifacey.cppm
g++ -std=c++26 -fmodules -Wall -Wextra -c implx.cpp
Output of the last command:
implx.cpp:4:1: error: recursive lazy load
4 | X::X(int v) : value(v) {}
| ^
implx.cpp:4:1: fatal error: failed to load pendings for '::Luna'
compilation terminated.
Removing the `table` declaration from the interface makes everything
pass, so the trigger is specifically the interface naming `Luna<X>`
while X is being completed in the implementation unit. No preprocessed
sources are attached: the reproducer includes no headers at all.
This looks like a remaining variant of c++/124953 (same error, also
in the lazy loader): that bug's reproducer passes on this compiler,
and Clang 22 accepts this shape -- it occurs in real code where bind
tables are declared in a module interface and defined in its
implementation unit.
Environment:
gcc version 16.2.1 20260810 (GCC)
Target: x86_64-pc-linux-gnu, Thread model: posix
Configured with: ../gcc/configure --enable-languages=ada,c,c++,d,
fortran,go,lto,m2,objc,obj-c++,rust,cobol --enable-bootstrap
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://github.com/CachyOS/CachyOS-PKGBUILDS/issues
--with-build-config=bootstrap-lto --with-gcc-major-version-only
--with-linker-hash-style=gnu --with-system-zlib --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-libstdcxx-backtrace
--enable-link-serialization=1 --enable-linker-build-id --enable-lto
--enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-fixincludes --disable-libssp
--disable-libstdcxx-pch --disable-werror