Crash when lowering a Carbon derived class that overrides a C++ base class with virtual functions

Author: zygoloidCreated Sep 3, 2026Updated Sep 3, 2026
Labelstoolchain

Description of the bug:

No response

What did you do, or what's a simple way to reproduce the bug?

import Cpp inline '''
struct X { virtual void f() {} };
''';

class Z {
    extend base: Cpp.X;
    override fn f(unused self) {}
}

fn Run() {
    var _: Z = {.base = Cpp.X.X()};
}

What did you expect to happen?

No response

What actually happened?

Crash:

Stack dump:
[...]
 #4 0x00005fc4256e4c12 Carbon::Lower::FileContext::BuildVtable(Carbon::SemIR::Vtable const&, Carbon::SemIR::SpecificId) (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x248bc12)
 #5 0x00005fc4256e458f Carbon::Lower::FileContext::PrepareToLower() (/opt/compiler-explorer/carbon-trunk/bin/carbon+0x248b58f)

Any other information, logs, or outputs that you want to share?

No response

Source: carbon-language/carbon-lang