[clang-cl] clang-cl fails to link (emit?) the vtable for a type in a dll with: multiple and virtual inheritance, and inherited constructor
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
This is the pattern:
```c++
// where API is appropriately defined to __declspec(dllimport/export)
class API some_class : virtual public a, public b {
public:
using b::b;
~some_class(); // defining the dtor works to export the vtable on all compilers besides clang-cl
virtual void pure_virtual_method_from_a() override;
};
```
This class cannot be linked against. The error is: `undefined symbol: __declspec(dllimport) const some_class::`vbtable'`
I don't know whether the bug is that the client can't link with the vtable or that the compiler didn't emit the vtable at all.
This gets resolved if the constructor of `b` is not inherited, but explicitly invoked as in:
```c++
some_class(b_args args) : b(std::move(args)) {}
```
Obviously, it's quite annoying to delegate multiple constructors verbatim.
Live demo here:
https://github.com/iboB/clang-cl-vtable-link-bug/actions/runs/23292990137/job/67733078363
This links successfully build with linux clang, apple clang and msvc, but not with clang-cl
Contributor guide
Research direction
Start with the linked GitHub Actions live demo and reproduce the clang-cl failure using the shown C++ pattern with virtual and multiple inheritance plus an inherited constructor. Compare the result with Linux Clang, Apple Clang, and MSVC, then determine whether the missing vbtable symbol is caused by vtable emission or client linking. Done means the example links successfully with clang-cl without manually delegating the constructors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100