Skip to content

[clang] "Assertion `ESD->getInstantiations() && "expansion statement not expanded?"' failed." with lambda #212088

Description

@efriedma-quic

https://godbolt.org/z/MKWG5sz8c

void f() {
  struct S {};
  template for (const int &x : []{return S();}()) {
  }
}
clang++: /root/llvm-project/llvm/tools/clang/lib/CodeGen/CGDecl.cpp:149: void clang::CodeGen::CodeGenFunction::EmitDecl(const clang::Decl&, bool): Assertion `ESD->getInstantiations() && "expansion statement not expanded?"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -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++2c <source>
1.	<eof> parser at end of file
2.	<source>:1:6: LLVM IR generation of declaration 'f'
3.	<source>:1:6: Generating code for declaration 'f'
 #0 0x0000000004421578 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4421578)
 #1 0x000000000441e424 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x441e424)
 #2 0x000000000441ea5c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x441ea5c)
 #3 0x000000000435da38 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x0000738c16245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x0000738c1629eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
 #6 0x0000738c1624527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x0000738c162288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x0000738c1622881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #9 0x0000738c1623b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x0000000004e81cc2 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e81cc2)
#11 0x0000000004aa139c clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4aa139c)
#12 0x0000000004abb1a7 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4abb1a7)
#13 0x0000000004ab2ae8 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ab2ae8)
#14 0x0000000004abad5b clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4abad5b)
#15 0x0000000004b23786 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b23786)
#16 0x0000000004b39024 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b39024)
#17 0x0000000004ba94aa clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ba94aa)
#18 0x0000000004ba2854 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ba2854)
#19 0x0000000004ba3043 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ba3043)
#20 0x0000000004bb0719 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#21 0x0000000004f2e419 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#22 0x0000000004f1f4c4 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f1f4c4)
#23 0x0000000006d2d934 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d2d934)
#24 0x0000000004f2c288 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f2c288)
#25 0x0000000005259508 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5259508)
#26 0x00000000051e60cd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x51e60cd)
#27 0x000000000532dc4d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x532dc4d)
#28 0x0000000000daf4dc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdaf4dc)
#29 0x0000000000da60ea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#30 0x0000000000da626d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#31 0x0000000004fa3749 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
#32 0x000000000435de74 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x435de74)
#33 0x0000000004fa42b5 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
#34 0x0000000004f5ca92 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f5ca92)
#35 0x0000000004f612c7 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+++0x4f612c7)
#36 0x0000000004f6b825 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f6b825)
#37 0x0000000000dab9ca clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdab9ca)
#38 0x0000000000cc5c5a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcc5c5a)
#39 0x0000738c1622a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#40 0x0000738c1622a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#41 0x0000000000da5a95 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda5a95)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134

Metadata

Metadata

Assignees

Labels

c++26clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions