Skip to content

Clang hits assertion when using virual consteval functions: VTableBuilder.cpp:2281 I != MethodVTableIndices.end() && "Did not find index!"' failed. #55065

Closed
@ArXen42

Description

@ArXen42

How to reproduce

struct Base
{
	consteval virtual int Get() const = 0;
};

struct Derived : Base
{
	consteval int Get() const override
	{
		return 42;
	}
};

int main()
{
	constexpr Derived a;

	auto val = a.Get();
	return 0;
}

Compiler explorer link (clang-14, -std=c++20, no optimizations or other options):
https://godbolt.org/z/vhqGqvf1z

Replacing 'consteval' with 'constexpr', moving a creation out of the function scope or removing inheritance seems to fix this compiler crash.

Attached cpp/sh crash reproduction files from my local compiler (clang 13.0.1-2 from Arch Linux repos):
main-fee9e9..zip

Metadata

Metadata

Assignees

Labels

c++20clang:codegenIR generation bugs: mangling, exceptions, etc.confirmedVerified by a second partyconstevalC++20 constevalcrashPrefer [crash-on-valid] or [crash-on-invalid]

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions