<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/76181>76181</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[ICE] AST parser fails after out-of-line constructor requires clause
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cuzdav
</td>
</tr>
</table>
<pre>
Hi, using clang 17 the following code crashes the parser (tested using x86 linux builds). I narrowed it down to this code on Compiler Explorer (https://godbolt.org/z/j35Tvqvvj) and while at this time CE only has clang 17.0.1, it is present in every version up through 17.0.5 and also in the current trunk. [Clang 16 gives a false error message but doesn't crash.]
-std=c++20
```cpp
template <auto... Values>
struct Foo {
Foo(auto... args)
requires(sizeof...(args) == sizeof...(Values));
};
template <auto... Values>
Foo<Values...>::Foo(auto... args)
requires(sizeof...(args) == (sizeof...(Values))) {}
```
```
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-17.0.1/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-13.2.0 -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1. <source>:9:54: current parser token '{'
#0 0x0000000003349f18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3349f18)
#1 0x0000000003348044 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3348044)
#2 0x000000000329c028 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f0e98c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00000000063a2856 clang::LocalInstantiationScope::findInstantiationOf(clang::Decl const*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x63a2856)
#5 0x000000000643acd0 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-17.0.1/bin/clang+++0x643acd0)
#6 0x00000000063bd3e7 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformSizeOfPackExpr(clang::SizeOfPackExpr*) SemaTemplateInstantiate.cpp:0:0
#7 0x00000000063a96a3 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#8 0x00000000063adb2b clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformBinaryOperator(clang::BinaryOperator*) SemaTemplateInstantiate.cpp:0:0
#9 0x00000000063a9eaa clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#10 0x00000000063b4d65 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformParenExpr(clang::ParenExpr*) SemaTemplateInstantiate.cpp:0:0
#11 0x00000000063a9842 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#12 0x00000000063d886f clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x63d886f)
#13 0x0000000005b67257 SubstituteConstraintExpression(clang::Sema&, clang::NamedDecl const*, clang::Expr const*) SemaConcept.cpp:0:0
#14 0x0000000005b69753 clang::Sema::AreConstraintExpressionsEqual(clang::NamedDecl const*, clang::Expr const*, clang::NamedDecl const*, clang::Expr const*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x5b69753)
#15 0x000000000617e373 clang::Sema::IsOverload(clang::FunctionDecl*, clang::FunctionDecl*, bool, bool, bool) (.part.0) SemaOverload.cpp:0:0
#16 0x000000000617ea82 clang::Sema::CheckOverload(clang::Scope*, clang::FunctionDecl*, clang::LookupResult const&, clang::NamedDecl*&, bool) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x617ea82)
#17 0x0000000005c34848 clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x5c34848)
#18 0x0000000005c3c3c5 clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x5c3c3c5)
#19 0x0000000005c3ffc0 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x5c3ffc0)
#20 0x0000000005c40a08 clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::Sema::SkipBodyInfo*, clang::Sema::FnBodyKind) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x5c40a08)
#21 0x00000000058caaf0 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58caaf0)
#22 0x00000000059c7f9f clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x59c7f9f)
#23 0x00000000059cfb71 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x59cfb71)
#24 0x00000000059cfe33 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x59cfe33)
#25 0x00000000058fe460 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58fe460)
#26 0x00000000058cd199 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58cd199)
#27 0x00000000058cef0a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58cef0a)
#28 0x00000000058be95a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x58be95a)
#29 0x00000000044f8b05 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x44f8b05)
#30 0x0000000003dd5f21 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3dd5f21)
#31 0x0000000003d5b9fb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3d5b9fb)
#32 0x0000000003eb5c23 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3eb5c23)
#33 0x0000000000bd50c5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0xbd50c5)
#34 0x0000000000bce42d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#35 0x0000000003ba7489 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
#36 0x000000000329c453 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x329c453)
#37 0x0000000003ba76a9 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
#38 0x0000000003b6f477 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3b6f477)
#39 0x0000000003b6fe2d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3b6fe2d)
#40 0x0000000003b79d0c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0x3b79d0c)
#41 0x0000000000bd2d31 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0xbd2d31)
#42 0x0000000000acf511 main (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0xacf511)
#43 0x00007f0e98c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#44 0x00007f0e98c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#45 0x0000000000bcdc2e _start (/opt/compiler-explorer/clang-17.0.1/bin/clang+++0xbcdc2e)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkW11zoziX_jXkRmUXCDBwkQvHid83sz2bVDs7e5kS4mBrgiVaEonTv35LAtuI2J7-oHdnaqcysSMJ6TnP-ZRQE6XYmgNce_GNF99ekUZvhLymzdeCvF7loni__jfz8AI1ivE1ohXhaxQkSG8AlaKqxJttFgUgKonagLJdNZEKJPJwqkFpKLrHd-kMVYw3O5Q3rCqUh7MpQveIEynFGxSIaVSIN460QHrDVDux4GghtjWrQKK7XV0J2U690bpWXjj38NLDy7UoclHpqZBrDy-_enj5Zxg_vX55ff3TwxkivEBvG1YBIrqdW7MtoMUdErx6RxuiDsJN_WlgRGYaMYVqCQq4RowjeAX5jl5BKiY4amqkN1I06037TGzXIJUSZqxhgTZSmke1bPjLFCEvvlm0a8zQmr2CQgSVpFKAQEoh0RaUImtAeWNoAMU9nOiW16kX33r-refP298TpQsvvKUevvHwDfb7fd3vmd_-0LpuWzRs64poQF64II0W0-kU_UGqBpQX3rVDlJYN1WgpBPKSm7YNIWQaPJzuHyJybVTXdUv40jAJysOpYl9BlNPp1AxuByEvvPXCW9Tv6hbFmfkJu2W85Pb4_VvxGlzhom00c4d3xh7C-c_jHfQ6kM2o5MYAdpk-SX_75-Onu_nqDqkm3zKNCMqbNZJQC6mNrQ8smelNk0-p2Hp4WVWv-49JLcWfQLWHl0wpC2dpbY5xWjUFtDZnrAXlhL5oSSgYO64l1FJQUAoKpEQj22ZrrUoJyojxUNlwpKhktZ62kFea0BdUNNvaILNN_tTzs0cp1pJsDavNFrg2wJGHl6I2yGjnqRPoPNW0GaOf7B1rmTO-b2zNF03WxRuR5SRCkzWaCDMbqWszZ6PrRk8VmmwNA2gy2aWzCVHbiXrnmuy88JZxDRWarNBksqZ0ooWo6IYwbvR4CZQZHIRTPPXRpKSiEnJSMLLmQmlGFZqUXEwsmW7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