https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122819
Bug ID: 122819
Summary: Linkage of temploid friends attached to named modules
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: link-failure
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:
// a.cpp
export module M;
export template <typename T> struct S {
friend void f(S) {}
};
// b.cpp
import M;
void test() {
f(S<int>{});
}
// c.cpp
import M;
int main() {
f(S<int>{});
}
$ g++ -fmodules [abc].cpp
/usr/bin/ld: /tmp/ccyorFKr.o: in function `foo@M(S@M<int>)':
c.cpp:(.text+0x10): multiple definition of `foo@M(S@M<int>)';
/tmp/ccvQcSbK.o:b.cpp:(.text+0xc): first defined here
collect2: error: ld returned 1 exit status
'f' here is not implicitly 'inline', because it is attached to a named module.
And we should not mark it as such to prevent escaping TU-local exposures. But
it is still a templated entity ([temp.pre] p8), and so we should still mark it
as COMDAT.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524
[Bug 103524] [meta-bug] modules issue