crash when overriding a virtual function from a C++ class with multiple inheritance
Author: zygoloidCreated Sep 3, 2026Updated Sep 3, 2026
Labelstoolchain
Description of the bug:
When a C++ class has multiple inheritance, we don't expose its base classes to Carbon. If a base class introduces a virtual function and the Carbon derived class attempts to override that function, the toolchain crashes.
What did you do, or what's a simple way to reproduce the bug?
import Cpp inline '''
struct A { virtual void f() = 0; };
struct B { virtual void g() = 0; };
struct C : A, B {};
''';
class D {
extend base: Cpp.C;
override fn f(self) {}
override fn g(self) {}
}
fn Run() {
var d: D = {};
}
What did you expect to happen?
Either an error (ideally related to the multiple inheritance, but saying that we can't do the derived-to-base conversion would be OK) or compilation success, overriding both virtual functions in the two vtprs inside D.
What actually happened?
CHECK failure at toolchain/check/convert.cpp:2525: path.has_value(): only derived-to-base conversions can currently be undone
Any other information, logs, or outputs that you want to share?
We might want to reject when completing the type of class D instead, on the basis that we don't support classes with multiple vptrs yet?
Source: carbon-language/carbon-lang