https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120962
Bug ID: 120962 Summary: " XXX references internal linkage entity YYY" when compiling a module interface Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: markus.parker at arcor dot de Target Milestone: --- The following module interface file does not compile: export module moduleTest; namespace { void bar(){} } template<class T> struct scalar_traits { static void type_bar (const T& t) { bar(); } }; export int foo() { return 0; } Compiling yields: /xxx # g++ -c -std=c++20 -fmodules-ts ModuleTest.cxx ModuleTest.cxx:11:15: error: 'template<class T> static void scalar_traits<T>::type_bar(const T&)' references internal linkage entity 'void {anonymous}::bar()' 11 | static void type_bar (const T& t) { | ^~~~~~~~ ModuleTest.cxx:3:9: error: failed to write compiled module: Bad file data 3 | export module moduleTest; | ^~~~~~ ModuleTest.cxx:3:9: note: compiled module file is 'gcm.cache/moduleTest.gcm' /xxx # If scalar_traits is not a template struct or void bar() is not within an anonymous namespace, the code compiles. This seems similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112621, but if I understand correctly, this should be fixed in 14.2. /xxx # gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/14.2.0/lto-wrapper Target: x86_64-alpine-linux-musl Configured with: /home/buildozer/aports/main/gcc/src/gcc-14.2.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --enable-checking=release --disable-cet --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-default-ssp --enable-languages=c,c++,d,objc,go,fortran,ada --enable-link-serialization=2 --enable-linker-build-id --disable-libssp --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-bugurl=https://gitlab.alpinelinux.org/alpine/aports/-/issues --with-system-zlib --with-linker-hash-style=gnu --with-pkgversion='Alpine 14.2.0' Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.2.0 (Alpine 14.2.0)