<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60890>60890</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[C++20] [Modules] definition with same mangled name as another definition
</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 valid set of files:
```cpp
export module a;
export template<typename T>
struct a {
friend bool aa(a const & lhs) requires(true) {
return static_cast<void>(lhs), true;
}
};
```
```cpp
export module b;
import a;
struct b {
a<int> m;
};
```
```cpp
export module c;
import a;
export struct c {
void f() const {
aa(m);
}
a<int> m;
};
```
```cpp
import a;
import b;
import c;
void d() {
aa(c().m);
}
```
And compiling with
```shell
clang++ -std=c++20 -x c++-module --precompile -c a.cpp -o a.pcm
clang++ -std=c++20 -fmodule-file=a=a.pcm -x c++-module --precompile -c b.cpp -o b.pcm
clang++ -std=c++20 -fmodule-file=a=a.pcm -x c++-module --precompile -c c.cpp -o c.pcm
clang++ -std=c++20 -fmodule-file=a=a.pcm -fmodule-file=b=b.pcm -fmodule-file=c=c.pcm -c d.cpp -o /dev/null
```
Fails with
```
In file included from d.cpp:1:
a.cpp:5:14: error: definition with same mangled name '_ZW1a2aaRKS_1aIiE' as another definition
friend bool aa(a const & lhs) requires(true) {
^
a.cpp:5:14: note: previous definition is here
1 error generated.
```
Note that changing the order of importing `b` and `c` in `d.cpp` causes the issue to go away.
Tested with 70d78e035801a35c95c55384621724b0ef8ecb35, but has existed for much longer.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VlGPo7YT_zTOyygRmEDgIQ-bzeav01_tQ3tSpb6cBnsAV8amtsnefvvKQG6Tba7daquiQOwZZn7zm8Fjo_eqNUR7lh9YflzhGDrr9hLPSvpgDa1qK1_2_1NnMhA6gsZqbZ-VaeGMWknwFMA20ChNnmUPL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