<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/119947>119947</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[C++][Modules] Definition with same mangled name for template arguments of types defined in unnamed namespace in different files
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
davidstone
</td>
</tr>
</table>
<pre>
Given the following translation units:
```c++
export module a;
struct a_inner {
~a_inner() {
}
void f(auto) {
}
};
export template<typename T>
struct a {
a() {
struct local {};
inner.f(local());
}
private:
a_inner inner;
};
namespace {
struct s {
};
} // namespace
void f() {
a<s> x;
}
```
```c++
import a;
namespace {
struct s {
};
} // namespace
void g() {
a<s> x;
}
```
clang fails with
```console
/opt/compiler-explorer/clang-assertions-trunk/bin/clang++ --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 -MD -MT CMakeFiles/foo.dir/b.cpp.o -MF CMakeFiles/foo.dir/b.cpp.o.d @CMakeFiles/foo.dir/b.cpp.o.modmap -o CMakeFiles/foo.dir/b.cpp.o -c /app/b.cpp
In file included from /app/b.cpp:1:
a.cpp:11:8: error: definition with same mangled name '_ZNW1a1aIN12_GLOBAL__N_11sEED2Ev' as another definition
11 | struct a {
| ^
a.cpp:11:8: note: previous definition is here
```
See it live: https://godbolt.org/z/vsdznvsbP
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVVFvpDYQ_jXelxErMGwIDzxswnI66XKt1JMq9WVl8ADuGRvZhuTuob-9siHZTe7aSFWRJWBmPN_nGc8Ms1b0CrEkhztyqHZsdoM2JWeL4NZphbtG82_lB7GgAjcgdFpK_ShUD84wZSVzQiuYlXCWpEcSh3UTr6sl9M6v-IhPkzYORs1nicBIereaWmfm1gE7C6XQAMlXefHXJiH0ltDiIid5tX4sWnDoCL1ls9M_M8m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