<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92230>92230</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Trunk crashes on trying to indexing an empty pack inside a lambda
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RungeCC
</td>
</tr>
</table>
<pre>
[Minimal example](https://godbolt.org/z/orbo4nj3z).
- clang version, chunk(c5cd049566a795ba5de88dfbb2eb563cad4a9d8a);
- flag `-std=c++26`
```c++
void ICE(auto...args){
[&]<int idx>(){
using R = decltype( args...[idx] ) ;
}.template operator()<0>();
}
int main( ) {
ICE(); // empty pack
}
```
Crash report:
```
clang++: /root/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:4544: llvm::PointerUnion<clang::Decl*, llvm::SmallVector<clang::VarDecl*, 4>*>* clang::LocalInstantiationScope::findInstantiationOf(const clang::Decl*): Assertion `isa<LabelDecl>(D) && "declaration not instantiated in this scope"' 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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++26 <source>
1. <eof> parser at end of file
2. <source>:1:6: instantiating function definition 'ICE<>'
3. <source>:2:3: instantiating function definition 'ICE()::(anonymous class)::operator()<0>'
#0 0x00000000039a1548 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39a1548)
#1 0x000000000399f22c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x399f22c)
#2 0x00000000038f0288 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007331a5e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007331a5e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007331a5e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007331a5e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007331a5e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007331a5e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000006ea971c clang::LocalInstantiationScope::findInstantiationOf(clang::Decl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ea971c)
#10 0x0000000006f63719 clang::Sema::CheckParameterPacksForExpansion(clang::SourceLocation, clang::SourceRange, llvm::ArrayRef<std::pair<llvm::PointerUnion<clang::TemplateTypeParmType const*, clang::NamedDecl*>, clang::SourceLocation>>, clang::MultiLevelTemplateArgumentList const&, bool&, bool&, std::optional<unsigned int>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f63719)
#11 0x0000000006ebabc3 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformPackIndexingExpr(clang::PackIndexingExpr*) SemaTemplateInstantiate.cpp:0:0
#12 0x0000000006eb21ad clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#13 0x0000000006ec16ba clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateInstantiate.cpp:0:0
#14 0x0000000006ec7d8a clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformType(clang::TypeSourceInfo*) SemaTemplateInstantiate.cpp:0:0
#15 0x0000000006ed1c1a clang::Sema::SubstType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ed1c1a)
#16 0x0000000006f55f41 clang::TemplateDeclInstantiator::InstantiateTypedefNameDecl(clang::TypedefNameDecl*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f55f41)
#17 0x0000000006f56684 clang::TemplateDeclInstantiator::VisitTypeAliasDecl(clang::TypeAliasDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f56684)
#18 0x0000000006f58474 void llvm::function_ref<void ()>::callback_fn<clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&)::'lambda'()>(long) SemaTemplateInstantiateDecl.cpp:0:0
#19 0x000000000642c7c1 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x642c7c1)
#20 0x0000000006efff7a clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6efff7a)
#21 0x0000000006eab315 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDeclStmt(clang::DeclStmt*) SemaTemplateInstantiate.cpp:0:0
#22 0x0000000006eee6d4 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#23 0x0000000006ef5d3a clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ef5d3a)
#24 0x0000000006f4d368 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f4d368)
#25 0x000000000642c7c1 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x642c7c1)
#26 0x0000000006e1cdc2 clang::Sema::DeduceReturnType(clang::FunctionDecl*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e1cdc2)
#27 0x000000000683c2ba clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*, llvm::ArrayRef<clang::SourceLocation>, clang::ObjCInterfaceDecl const*, bool, bool, clang::ObjCInterfaceDecl*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x683c2ba)
#28 0x0000000006c6564f clang::Sema::BuildCallToMemberFunction(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c6564f)
#29 0x00000000068a6e81 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x68a6e81)
#30 0x00000000068a9c9c clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x68a9c9c)
#31 0x0000000006ebdcd0 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*) SemaTemplateInstantiate.cpp:0:0
#32 0x0000000006eb1d5d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#33 0x0000000006eed8ff clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*, clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::StmtDiscardKind) SemaTemplateInstantiate.cpp:0:0
#34 0x0000000006eee6d4 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#35 0x0000000006ef5d3a clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ef5d3a)
#36 0x0000000006f4d368 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f4d368)
#37 0x0000000006f4b5ef clang::Sema::PerformPendingInstantiations(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6f4b5ef)
#38 0x000000000644f0cf clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (.part.0) Sema.cpp:0:0
#39 0x000000000644f8ca clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x644f8ca)
#40 0x00000000062ca1da clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62ca1da)
#41 0x00000000062bda9a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62bda9a)
#42 0x000000000426f478 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x426f478)
#43 0x00000000044f2bd9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44f2bd9)
#44 0x000000000447a2be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x447a2be)
#45 0x00000000045d9a9e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45d9a9e)
#46 0x0000000000c523fc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc523fc)
#47 0x0000000000c4b75a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#48 0x00000000042b2699 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
#49 0x00000000038f0734 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38f0734)
#50 0x00000000042b2c8f 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
#51 0x0000000004278d45 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4278d45)
#52 0x00000000042797ad 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+++0x42797ad)
#53 0x00000000042814a5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42814a5)
#54 0x0000000000c4f905 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4f905)
#55 0x0000000000b30f94 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb30f94)
#56 0x00007331a5e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#57 0x00007331a5e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#58 0x0000000000c4b20e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4b20e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW11346gZ_jXKDcc-Evq-yIXHTraznenkTDLbyxwEyGFHAhVQ1tlf3wPItpDtbDIbT7ud9nQniYCX5314v0AIKcXWnNLLIH0XpKsL1OsHIS8_93xNl8uLSpAn0_SRcdaiBtANaruGBukqgMWD1p0K4kUArwN4vRakEo2eC7kO4PXvAbwWshIJ_zX-PYDlPAhXQbhw_84AbhBfg0cqFRM8gEuAH3r-NYAFTjEJkzLNMpSXaYVSQouC1FUFaZVmMUYkQSUpUADLIH63FVc3aA2CLJwpTYJ4hQP4LoDvYBZk4Xhe86f9_9DBPX0UjID3y6sAFqjXYj6fI7lWZoJ86AGAYQdmRu14ybgGjGyC2Ixw3cC2HwC9YnwNPoMgXgFCcaOfOhrAAhiZ8_k8SN-ZsekKBLAEOxUACPLVXNO2a5CmQHRUIi3kMEG8DPezbYcE-Wqsm0HVIsbNXFb0HrzTzY0FbrEAbTv9BDqEv06lbTkaC19KpB6ApJ2Q2iz4sZ52SQde44WZRwqhA3jdNI_trJPiV4rNn0O_64ZVAby-pS0aftwN2r_nSiOuGdJ0jrsuiBdJmiRGppFkpo8XN4JxTeUXbswnXjqZtmVFcRPAhbGpfffbFjXNLxQbSr3evyA5GpBYlhfuXzDq9kFg1OxxMcFvseioa6wZJ17bp9oYsuBKg2PASqPKQikqTWdjtkyhIF5-QBVtbC-71iu7ijALYAYCCI0tIWnlAy40YHuWCGAc6AemgLKoIAxgDmrEGkoGv7v5cLW4vQKqr1qmAQJVvx6WE2gBJo7M9ENfzbFoh8U7XEOmVE-VsSPEzey46QkF-oECbC2lQvirlghTw2onaScFpkpRApTopXtsRiKlBHYqyJ4DhSXr9AD5ViP8FZC-7XYWF86DsLyRYi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