<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/131709>131709</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
ICE on variable template initialized to IILE containing fold expression?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Eczbek
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/YM7vGETxY
```cpp
constexpr auto call(auto f) { return f(); }
template<int> int zero = 0;
template<int = 0>
int magic = ([](auto) {
return zero<call([]<int... i> {
return (0, ..., i);
})>;
})(0);
int main() { magic<>; }
```
```
clang version 21.0.0git (https://github.com/llvm/llvm-project.git 4b86a7f3860a3cb0368e308494f65c103c02fa18)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk-20250317/bin
Found candidate GCC installation: /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1
Selected GCC installation: /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
(in-process)
"/opt/compiler-explorer/clang-trunk-20250317/bin/clang-21" -cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name example.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -v -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-trunk-20250317/lib/clang/21 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1/backward -internal-isystem /opt/compiler-explorer/clang-trunk-20250317/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++23 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -mllvm --x86-asm-syntax=intel -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /app/output.s -x c++ <source>
clang -cc1 version 21.0.0git based upon LLVM 21.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1/x86_64-linux-gnu
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1/backward
/opt/compiler-explorer/clang-trunk-20250317/lib/clang/21/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
<source>:12:14: warning: expression result unused [-Wunused-value]
12 | int main() { magic<>; }
| ^~~~~~~
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-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++23 -v <source>
1. <eof> parser at end of file
2. <source>:6:5: instantiating variable definition 'magic<>'
3. <source>:6:5: Generating code for declaration 'magic'
#0 0x0000000003b6ed88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b6ed88)
#1 0x0000000003b6cecc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b6cecc)
#2 0x0000000003abc748 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000791af2842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000000000354a452 llvm::Type::isIntegerTy(unsigned int) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x354a452)
#5 0x0000000004136645 clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4136645)
#6 0x0000000003ef1db7 clang::CodeGen::CodeGenModule::EmitNullConstant(clang::QualType) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ef1db7)
#7 0x00000000040c0f2b clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40c0f2b)
#8 0x00000000040e07e5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40e07e5)
#9 0x00000000040e12e0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40e12e0)
#10 0x00000000040ea7d7 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#11 0x0000000006d1a8e8 clang::Sema::InstantiateVariableDefinition(clang::SourceLocation, clang::VarDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6d1a8e8)
#12 0x0000000006d1b6a9 clang::Sema::PerformPendingInstantiations(bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6d1b6a9)
#13 0x0000000006269e49 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (.part.0) Sema.cpp:0:0
#14 0x000000000626a5dd clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x626a5dd)
#15 0x00000000060cbdd3 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x60cbdd3)
#16 0x00000000060ba33a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x60ba33a)
#17 0x00000000044ec32d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44ec32d)
#18 0x00000000047d0191 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x47d0191)
#19 0x000000000474ebdb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x474ebdb)
#20 0x00000000048bffc3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x48bffc3)
#21 0x0000000000d638a1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd638a1)
#22 0x0000000000d5c09d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#23 0x0000000004539629 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
#24 0x0000000003abcb63 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3abcb63)
#25 0x0000000004539849 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
#26 0x00000000044fcb6d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44fcb6d)
#27 0x00000000044fdb31 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44fdb31)
#28 0x0000000004507ecc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4507ecc)
#29 0x0000000000d60671 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd60671)
#30 0x0000000000c21cb4 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc21cb4)
#31 0x0000791af2829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#32 0x0000791af2829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#33 0x0000000000d5bb35 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd5bb35)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWk9z27iS_zTwBQUVCervwQdGsv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