<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/81430>81430</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
C++20 Frontend crash in CheckParameterPacksForExpansion
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JacobBaumgarte
</td>
</tr>
</table>
<pre>
When compiling the following code, clang 17.0.6 crashes. When I tested with clang 16.0.6, the program compiled without issue.
```
//compiled with /usr/bin/clang++-17 -std=c++20 main.cpp -c
//the crash occurs without the '-c' flag
struct parent{};
template<typename T>
struct child : public parent
{
template<typename ... V>
constexpr child(V... args) requires(requires{ parent(args...); });
};
template<typename T>
template<typename ... V>
constexpr child<T>::child(V... args) requires(requires{ parent(args...); })
{
}
```
```
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: /usr/bin/clang++-17 -std=c++20 main.cpp -c
1. main.cpp:15:1: current parser token '{'
#0 0x00007f8894ad80ea llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xcd80ea)
#1 0x00007f8894ad6324 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xcd6324)
#2 0x00007f8894a29bb4 (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xc29bb4)
#3 0x00007f8893642990 (/lib/x86_64-linux-gnu/libc.so.6+0x42990)
#4 0x00007f889cfc77ae 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>&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x19c77ae)
#5 0x00007f889cf5d3a1 (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x195d3a1)
#6 0x00007f889cf63253 (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x1963253)
#7 0x00007f889cf718e3 (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x19718e3)
#8 0x00007f889cf69269 (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x1969269)
#9 0x00007f889cf68ec3 (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x1968ec3)
#10 0x00007f889cf5cdb6 clang::Sema::SubstConstraintExpr(clang::Expr*, clang::MultiLevelTemplateArgumentList const&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x195cdb6)
#11 0x00007f889c95304b (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x135304b)
#12 0x00007f889c952e33 clang::Sema::AreConstraintExpressionsEqual(clang::NamedDecl const*, clang::Expr const*, clang::NamedDecl const*, clang::Expr const*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x1352e33)
#13 0x00007f889cdc3292 clang::Sema::IsOverload(clang::FunctionDecl*, clang::FunctionDecl*, bool, bool, bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x17c3292)
#14 0x00007f889cdc2d68 clang::Sema::CheckOverload(clang::Scope*, clang::FunctionDecl*, clang::LookupResult const&, clang::NamedDecl*&, bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x17c2d68)
#15 0x00007f889c9b7379 clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x13b7379)
#16 0x00007f889c9ab340 clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x13ab340)
#17 0x00007f889c9a6bcb clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x13a6bcb)
#18 0x00007f889c9c4293 clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::Sema::SkipBodyInfo*, clang::Sema::FnBodyKind) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x13c4293)
#19 0x00007f889c111722 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xb11722)
#20 0x00007f889c0ff69b clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xaff69b)
#21 0x00007f889c0fdce2 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xafdce2)
#22 0x00007f889c0fd68a clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xafd68a)
#23 0x00007f889c05b28e clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa5b28e)
#24 0x00007f889c10f00a clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xb0f00a)
#25 0x00007f889c10db99 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xb0db99)
#26 0x00007f889c0482fe clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0xa482fe)
#27 0x00007f889dd92439 clang::FrontendAction::Execute() (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x2792439)
#28 0x00007f889dd0bdb4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x270bdb4)
#29 0x00007f889de0d054 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x280d054)
#30 0x0000556a4207a21b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang++-17+0x1421b)
#31 0x0000556a42077c25 (/usr/bin/clang++-17+0x11c25)
#32 0x00007f889d9cb24d (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x23cb24d)
#33 0x00007f8894a29944 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xc29944)
#34 0x00007f889d9caa32 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x23caa32)
#35 0x00007f889d99390e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x239390e)
#36 0x00007f889d993b6e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x2393b6e)
#37 0x00007f889d9af53e clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/llvm-17/bin/../lib/libclang-cpp.so.17+0x23af53e)
#38 0x0000556a42077576 clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang++-17+0x11576)
#39 0x0000556a42084306 main (/usr/bin/clang++-17+0x1e306)
#40 0x00007f8893628150 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#41 0x00007f8893628209 call_init ./csu/../csu/libc-start.c:128:20
#42 0x00007f8893628209 __libc_start_main ./csu/../csu/libc-start.c:347:5
#43 0x0000556a42074555 _start (/usr/bin/clang++-17+0xe555)
clang++-17: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 17.0.6 (++20240124120726+6009708b4367-1~exp1~20240124120743.47)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang++-17: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++-17: note: diagnostic msg: /tmp/main-fae662.cpp
clang++-17: note: diagnostic msg: /tmp/main-fae662.sh
clang++-17: note: diagnostic msg:
********************
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWt9T67az_2vEi4aMLfnnAw8hkJZezhcG6OkjI8tKoosjuZLMCfehf_sdyY5jmYRDT91-O8OAsVb746PV7lpaojVfC8YuQHwJ4qsz0piNVBe_ECqLS9Js10QZdlbI8u3itw0TkMptzSsu1tBsGFzJqpLf7H9UlgygBaQVEWsYprNglkCqiN4wPYNu6g00TBtWwm_cbPaEiSW0Ey27Wsm1IttOSEcpGwO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