<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62442>62442</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
"error: pack expansion does not contain any unexpanded parameter packs" for capture, and ice
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ecatmur
</td>
</tr>
</table>
<pre>
```c++
auto f = [](auto) { return [](auto... a) { [](auto...) {}([a]{}...); }; }(0);
```
```
<source>:1:64: error: pack expansion does not contain any unexpanded parameter packs
auto f = [](auto) { return [](auto... a) { [](auto...) {}([a]{}...); }; }(0);
~~~~~^
<source>:1:74: note: in instantiation of function template specialization '(anonymous class)::operator()<int>' requested here
auto f = [](auto) { return [](auto... a) { [](auto...) {}([a]{}...); }; }(0);
^
```
The capture should qualify `[a]{}...` as an unexpanded parameter pack.
Workaround: discard `a` in the pack expression i.e. `(a, [a]{})...` or `((void)a, [a]{})...` to keep warnings happy.
Possibly related to #48731.
Probably related, this ices:
```c++
int i = [](auto) { return [](auto... a) { return ([a]{}, ..., 0); }; }(0)();
```
```
0. Program arguments: /opt/compiler-explorer/clang-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++20 -O3 <source>
1. <source>:1:75: current parser token ')'
2. <source>:1:27: instantiating function definition '(anonymous class)::operator()(int)::(anonymous class)::operator()<>'
#0 0x00005638e846745f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x356d45f)
#1 0x00005638e846548c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x356b48c)
#2 0x00005638e83b6a08 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f7503454420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00005638eb429c43 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformLambdaExpr(clang::LambdaExpr*) SemaTemplateInstantiate.cpp:0:0
#5 0x00005638eb42c372 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#6 0x00005638eb433fa5 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCXXFoldExpr(clang::CXXFoldExpr*) SemaTemplateInstantiate.cpp:0:0
#7 0x00005638eb42c6b2 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#8 0x00005638eb42d495 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool) SemaTemplateInstantiate.cpp:0:0
#9 0x00005638eb42eb87 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformReturnStmt(clang::ReturnStmt*) SemaTemplateInstantiate.cpp:0:0
#10 0x00005638eb45c9e3 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#11 0x00005638eb461925 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6567925)
#12 0x00005638eb4aa4b0 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x65b04b0)
#13 0x00005638eaac9fa5 clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5bcffa5)
#14 0x00005638eb3acfa9 clang::Sema::DeduceReturnType(clang::FunctionDecl*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x64b2fa9)
#15 0x00005638eae848d7 clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*, llvm::ArrayRef<clang::SourceLocation>, clang::ObjCInterfaceDecl const*, bool, bool, clang::ObjCInterfaceDecl*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5f8a8d7)
#16 0x00005638eb1f678e CreateFunctionRefExpr(clang::Sema&, clang::FunctionDecl*, clang::NamedDecl*, clang::Expr const*, bool, clang::SourceLocation, clang::DeclarationNameLoc const&) SemaOverload.cpp:0:0
#17 0x00005638eb23c0b8 clang::Sema::BuildCallToObjectOfClassType(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63420b8)
#18 0x00005638eaee1b45 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5fe7b45)
#19 0x00005638eaf02d3b clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6008d3b)
#20 0x00005638ea9e313a clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5ae913a)
#21 0x00005638ea9daba7 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5ae0ba7)
#22 0x00005638ea9ddd7e clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5ae3d7e)
#23 0x00005638ea9ddf7d clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5ae3f7d)
#24 0x00005638ea99b39c clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5aa139c)
#25 0x00005638ea9af046 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5ab5046)
#26 0x00005638ea9779b7 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5a7d9b7)
#27 0x00005638ea978b0f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#28 0x00005638ea980594 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5a86594)
#29 0x00005638ea981b4d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5a87b4d)
#30 0x00005638ea9820e4 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5a880e4)
#31 0x00005638ea970e9a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5a76e9a)
#32 0x00005638e95c7f25 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x46cdf25)
#33 0x00005638e8eb5cd1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3fbbcd1)
#34 0x00005638e8e38e13 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f3ee13)
#35 0x00005638e8f96183 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x409c183)
#36 0x00005638e5d6739c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xe6d39c)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWktz2zjW_TX0BiUVCfC58EKW7f5SX3qcij3VvXOBwKWEDgWwATCRZzG_fQqkHgRFa5xuuaeTciwKz3vOPbi4gEmNESsJcB0kN0Fye0Vbu1b6Ghi1m1ZflYq_XAdp2P-wAN-4n_A2CBe0tQpVKCC3qO8b4NyVBbhAQXaDNNhWS79uPp8jum8wrtmVB5krC5Ib6mq7731lQG6Qq9x94DzsC3tzDkZOfyVLo1rNICB3AVlEAVmkcUAWCLRW2j00lH1BsG2oNEJJxBUYJJVFTElLhURUvqBWdg04cNRQTTdgQXcdzd-SEvRv9y9I7l7lIOs4kMqC-xQSCWkslVZQ60hQFapaybpnC5umphaQaYAJWot_9W0CnDl7pZIvG9UaxGpqTGfFIiAL1YCmVmlnvitbCmnd9DhDGn5vwVjgaA0a_p4EHrkbyan7_bQGxGhjWw3IrFVbc_R7S2tRvSDXcjxbGiJqEJWvy2g-HP0Xpb9QrVrJnW-4MIxq7gambiQhkV3DQbUaTCdbMYd5NznOaYCXyDMiwMXODqV3jQKcf1WCB7g419wq9AWgQd-olkKuDFrTpnnxrP2kjBFl_YI0OJVw1yfAJM4zEvkNtSrpoKGb1q6FQYKBcaIZtJ0OPEJaJP6ERvYNRoJwhnSiWKLwVWXsZPymmBPOg7D4pNVK0w2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