https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119527
Bug ID: 119527 Summary: [modules] Internal linkage virtual key function of template in header unit is not emitted Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nshead at gcc dot gnu.org Blocks: 103524 Target Milestone: --- Consider: // header.hpp namespace { template <typename T> struct S { virtual void key() {} }; S<int> s; } // main.cpp import "header.hpp"; int main() {} $ g++-15 -fmodule-header header.hpp header.hpp:3:18: warning: ‘void {anonymous}::S<T>::key() [with <template-parameter-1-1> = int]’ used but never defined 3 | virtual void key() {} | ^~~ $ g++-15 -fmodules -fno-module-lazy main.cpp /usr/bin/ld: /tmp/cc5etnIe.o:(.rodata+0x10): undefined reference to `(anonymous namespace)::S<int>::key()' collect2: error: ld returned 1 exit status The issue seems to be related to header modules skipping much of 'c_parse_final_cleanups', since by not emitting vtables there they sometimes miss instantiating template bodies, which leads to not only a confusing-looking warning when building the header but also results in the body never being emitted confusing importers as well. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524 [Bug 103524] [meta-bug] modules issue