<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/131641>131641</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`deferred extra vtables during vtable emission?` assertion fires
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
clang:codegen,
debuginfo,
confirmed,
crash
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Endilll
</td>
</tr>
</table>
<pre>
While reducing #124673, the following crash has surfaced (https://godbolt.org/z/cEzoeGz5e):
```cpp
struct PrimitiveImplCodec {
virtual void Write();
};
constexpr PrimitiveImplCodec DefaultedOf{};
template <auto>
struct Field {
using FieldType = Field;
};
typename Field<DefaultedOf>::FieldType RecordOf();
template <auto>
struct InlineFieldCodec {
virtual void WriteInline();
};
void GetPartCodec() {
constexpr InlineFieldCodec<RecordOf> QuadCodec;
// constexpr InlineFieldCodec<0> CubeCodec;
}
```
```
clang++: /root/llvm-project/clang/lib/CodeGen/CGVTables.cpp:1280:
void clang::CodeGen::CodeGenModule::EmitDeferredVTables():
Assertion `savedSize == DeferredVTables.size() && "deferred extra vtables during vtable emission?"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 -g0 -Xclang -debug-info-kind=constructor <source>
1. <eof> parser at end of file
2. Per-file LLVM IR generation
#0 0x0000000003e836b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e836b8)
#1 0x0000000003e81344 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e81344)
#2 0x0000000003dc61d8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007408c9e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007408c9e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007408c9e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007408c9e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007408c9e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007408c9e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000043b7313 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43b7313)
#10 0x00000000044457fb clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44457fb)
#11 0x0000000004447c33 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4447c33)
#12 0x000000000484225e (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#13 0x000000000483e705 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x483e705)
#14 0x000000000649dd2c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x649dd2c)
#15 0x000000000483eeb8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x483eeb8)
#16 0x0000000004b0e995 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b0e995)
#17 0x0000000004a90ade clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4a90ade)
#18 0x0000000004bfe6be clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bfe6be)
#19 0x0000000000d4f70f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd4f70f)
#20 0x0000000000d46eca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#21 0x0000000004887419 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#22 0x0000000003dc6674 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3dc6674)
#23 0x0000000004887a2f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#24 0x000000000484a49d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x484a49d)
#25 0x000000000484b52e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x484b52e)
#26 0x0000000004852c05 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4852c05)
#27 0x0000000000d4c508 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd4c508)
#28 0x0000000000c13de4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc13de4)
#29 0x00007408c9e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#30 0x00007408c9e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#31 0x0000000000d46975 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd46975)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWV1zo7jS_jXkRoULBObjIhceJ553tmZr553k7J47l5AaW2eEREnC48yvPyWBDTjO7GYr2Zsz5amA6G49_XSr1QJiDN9JgNtg-SFY3t2Qzu6Vvr2XjAshbirFnm7_2HMBSAPrKJc7FOAkxmmWJwFeI7sHVCsh1Hf3iGpi9mhPDDKdrgkFhgJc7K1tTZCsArwJ8GanWKWEXSi9C_DmR4A39P6Hgo8_lhDg0olFqyCL-h9t2yBaGas7atEXzRtu-QE-Na1YKwYUBfmHIFqhA9e2IwIdFGfoD80tBLjw1tzjIL8bLqIVVdJYOLb6mrU7qEknLLDfamd4omahaQWxgIJkTTqrguR-xLXhINgJCuqMY8KPPT61TuOuv3sOxj61IEkDp-frKYDk3nGRrEZLX4Eq7R5NffsTbJ-k4BK8jRljVyjrRV8izst9BPuFaOst9YJneyOxl1MGyfqMPLlH_9-R03iv2afFzw1ETnPdVTDRdOgmqXJxTQWRuwB_cL9k5SbRStkAb4Q4NGGr1X-AuttBbiN4FeCNM_8RpLv6-PsjqQSYhcvBZBXjIuqT0zPRq_kAnXSmN78q1gnoh-4bbu-gBq2BDTZPJDtzK2NAW64kCrLIkAOwB_7Dp43LnAvFheE_4MQ8zgKcoQBjNgghOFpN0MF6WcQ67VKxv0XQcGO4kkGyCTAOcI5qwgWwRR_fL5_vVw_3yHRVwy0iqOp2SEOrtEVWoYslzO2-qxZUNQOfz2nlxnTOzw0ikiEuqegY-GrR14iK0G9WEwquiLQaWq0oGAMMGdXpfthpEmMU5cQCQ7qTyFDNW-sgP1hCvyHWNW1PY7Q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