Issue |
97313
|
Summary |
[clang] Polymorhic class templates are broken in modules
|
Labels |
clang
|
Assignees |
|
Reporter |
jasiolpn
|
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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs