<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97780>97780</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-19 crash: bool clang::TreeTransform< <template-parameter-1-1> >::TransformExprs(clang::Expr* const*, unsigned int, bool, llvm::SmallVectorImpl<clang::Expr*>&, bool*) [with Derived = {anonymous}::TemplateInstantiator]: Assertion `!Unexpanded.empty() && "Pack expansion without parameter packs?"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
iamanonymouscs
</td>
</tr>
</table>
<pre>
### Description:
The following code causes a crash in clang++.
Also ICE on trunk, compiler explorer:https://godbolt.org/z/a1YeKdsEW
### OS and Platform:
```
# uname -a
Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
# clang++ -v
Ubuntu clang version 19.0.0 (++20240301064251+dd426fa5f931-1~exp1~20240301184412.1845)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-19/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Candidate multilib: .;@m64
Selected multilib: .;@m64
```
### Program:
```cpp
template <class... Ts>
void sink(Ts...);
template <class... Ts>
void f(Ts...) {
sink([] { struct alignas:Ts) S {}; }...); }
}
int main() {
f(0);
}
```
### Command Lines:
```
# clang++ z1.cpp -O1 -fsanitize=undefined -Wall -Wextra -pedantic -c -o z1.o
<source>:5:27: error: expected '('
5 | sink([] { struct alignas:Ts) S {}; }...); }
| ^
| (
<source>:5:30: error: expected '{' after base class list
5 | sink([] { struct alignas:Ts) S {}; }...); }
| ^
<source>:5:30: error: expected unqualified-id
<source>:6:1: error: extraneous closing brace ('}')
6 | }
| ^
clang++: /root/llvm-project/clang/lib/Sema/TreeTransform.h:4262: bool clang::TreeTransform< <template-parameter-1-1> >::TransformExprs(clang::Expr* const*, unsigned int, bool, llvm::SmallVectorImpl<clang::Expr*>&, bool*) [with Derived = {anonymous}::TemplateInstantiator]: Assertion `!Unexpanded.empty() && "Pack expansion without parameter packs?"' 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 -O1 -fsanitize=undefined -Wall -Wextra -pedantic <source>
1. <eof> parser at end of file
2. <source>:4:6: instantiating function definition 'f<int>'
#0 0x0000000003a385c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a385c8)
#1 0x0000000003a362bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a362bc)
#2 0x0000000003980688 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f2719e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f2719e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007f2719e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007f2719e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007f2719e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007f2719e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000070231fb clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExprs(clang::Expr* const*, unsigned int, bool, llvm::SmallVectorImpl<clang::Expr*>&, bool*) SemaTemplateInstantiate.cpp:0:0
#10 0x000000000702d641 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCallExpr(clang::CallExpr*) SemaTemplateInstantiate.cpp:0:0
#11 0x000000000702131d clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#12 0x000000000705e4bf clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*, clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::StmtDiscardKind) SemaTemplateInstantiate.cpp:0:0
#13 0x000000000705ec74 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#14 0x0000000007066aba clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7066aba)
#15 0x00000000070bf088 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70bf088)
#16 0x00000000070bd39f clang::Sema::PerformPendingInstantiations(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70bd39f)
#17 0x000000000655482f clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (.part.0) Sema.cpp:0:0
#18 0x000000000655502a clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x655502a)
#19 0x00000000063cb64a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63cb64a)
#20 0x00000000063bed6a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63bed6a)
#21 0x0000000004326808 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4326808)
#22 0x00000000045ad759 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45ad759)
#23 0x000000000453336e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453336e)
#24 0x0000000004695bae clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4695bae)
#25 0x0000000000c710c5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc710c5)
#26 0x0000000000c6a2ea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x0000000004369f39 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
#28 0x0000000003980b34 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3980b34)
#29 0x000000000436a52f 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
#30 0x000000000432ffc5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x432ffc5)
#31 0x0000000004330a2d 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+++0x4330a2d)
#32 0x0000000004338435 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4338435)
#33 0x0000000000c6e495 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc6e495)
#34 0x0000000000b46364 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb46364)
#35 0x00007f2719e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x00007f2719e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000c69d9e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc69d9e)
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/eJzsWl9z27gR_zTwC4YaEuDfBz_IspUmlzSes9ObPnlAEJTRUAAPAB35Hu6zdwBCf0DL7qljXTvTehJbIrG7v_1hd7EgSLTmK8HYJciuQHZ9QQbzKNUlJ2sipHhey0FTfVHL5vkSIDz-g9dMU8V7w6UAeA7iaxDP7x8ZbGXXyR9crCCVDYOUDJppSCBVRD9CLiDtiFgBdAXQ1WwUG3_POy3hx8UNlAIaNYjvAC0gleued0xBtuk7qZgCeP5oTK-tTbQEaLmSTS07M5NqBdDyN4CWJPk7-6nRN78cat8D_3oHiWjgbUdMK9V6Bx7ksf-3FYCDIGsGIzJe-czFsIFDPQgzwHSWZLM4QgmOVkwwxSkECCOURt_GAXdfbuEXKeCnQcCkggkGeI5jgOcJgt_uFxDFCMNNmT_k6eTPh79-A2jprE08OOQORk_jdW_P3YJPTGkurcVZPIshQOU4GsUojXGcxHmKsgSgq6ZJUd6SrK1wEiW_s02f_L4dlJRpmqBZUqYZQJWfWqJWzAA89yijnk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