<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97313>97313</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Polymorhic class templates are broken in modules
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jasiolpn
</td>
</tr>
</table>
<pre>
Hello,
Looks like I've found a new bug. I've compiled fresh LLVM (last commit ae570d82e8c021f45209830db8c9c7bb79bed394) and I tried to compile following files:
```c++
// Base.cppm
export module Mod:Base;
export template <class>
class Base
{
public:
constexpr Base();
constexpr virtual ~Base();
};
template <class X>
constexpr Base<X>::Base() = default;
template <class X>
constexpr Base<X>::~Base() = default;
```
```c++
// Sub.cppm
export module Mod:Sub;
import :Base;
export class Sub : public Base<int>
{
};
```
```c++
// Mod.cppm
export module Mod;
export import :Base;
export import :Sub;
```
```c++
// main.cpp
import Mod;
int main()
{
Base<int> *b = new Sub();
delete b;
}
```
Those files are compiled but the linker says:
```
/usr/bin/ld: CMakeFiles/vtable.dir/Sub.cppm.o:(.rodata+0xa): multiple definition of `typeinfo name for Base@Mod<int>'; CMakeFiles/vtable.dir/main.cpp.o:(.rodata+0x0): first defined here
/usr/bin/ld: CMakeFiles/vtable.dir/Sub.cppm.o:(.data.rel.ro+0x20): multiple definition of `typeinfo for Base@Mod<int>'; CMakeFiles/vtable.dir/main.cpp.o:(.data.rel.ro+0x20): first defined here
```
What is interesting is that if I make `Base` not to be template linker is doing its job successfully.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVs1u4zgTfBr60hiBpiRLOuhgJ5_xBUiABbLY3SsptmzGFCmQlCe5zLMvqJ8k3vzMDBBASBB2s1jVXWyGe68OBrEm-Y7k1ys-hKN19QP3yurerISVT_X_UWtL2BWh14Rub609edDqhHBDWHFGaO1gJHAw-B3EcEiW9cZ2vdIooXXoj3B7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