<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118423>118423</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] Crash involving lambda in unevaluated context referring to a template type parameter
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MagentaTreehouse
</td>
</tr>
</table>
<pre>
```c++
template <int>
struct A {
template <class F, class G = decltype([] { return F{}; })>
static auto foo(F, G g = {}) { g(); }
};
int main() {
A<0>::foo(0.);
}
```
Unreachable:
```console
undeduced type in IR-generation
UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:266!
```
Stack dump:
```console
0. Program arguments: /opt/compiler-explorer/clang-assertions-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++20 <source>
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. <source>:4:15: Generating code for declaration 'A<0>::foo'
#0 0x0000000003bf8558 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bf8558)
#1 0x0000000003bf625c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bf625c)
#2 0x0000000003b43708 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000075fca9042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000075fca90969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000075fca9042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000075fca90287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000000003b4f06a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b4f06a)
#8 0x0000000003fceaca clang::CodeGen::CodeGenFunction::getEvaluationKind(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fceaca)
#9 0x00000000043d9955 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43d9955)
#10 0x00000000043fd765 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43fd765)
#11 0x0000000003f5f395 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f5f395)
#12 0x0000000003f670d4 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f670d4)
#13 0x0000000003fd0124 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fd0124)
#14 0x0000000003fe30ec clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fe30ec)
#15 0x000000000404abfa clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x404abfa)
#16 0x0000000004045e95 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4045e95)
#17 0x000000000405203d clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x405203d)
#18 0x0000000004054323 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4054323)
#19 0x000000000457e28e (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#20 0x000000000457bf35 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x457bf35)
#21 0x00000000065215ec clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65215ec)
#22 0x000000000457c6e8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x457c6e8)
#23 0x0000000004837619 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4837619)
#24 0x00000000047b74de clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47b74de)
#25 0x000000000492252e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x492252e)
#26 0x0000000000cae8af cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcae8af)
#27 0x0000000000ca644a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x00000000045bf939 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
#29 0x0000000003b43bb4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b43bb4)
#30 0x00000000045bff2f 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
#31 0x00000000045861cd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45861cd)
#32 0x00000000045872bd 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+++0x45872bd)
#33 0x000000000458e675 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x458e675)
#34 0x0000000000cab6f3 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcab6f3)
#35 0x0000000000b7ffc4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb7ffc4)
#36 0x000075fca9029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#37 0x000075fca9029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#38 0x0000000000ca5efe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xca5efe)
```
Compiler Explorer: https://godbolt.org/z/5W6WTcnWd
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl9z4yj2_TTKCyWXDPpjPeRBceJM5tfz294k0_3oQgjJ2kagApRx9tNvAXJkFKe70xVPbdV2uSsSgss5h8vlgoSVahtO6WWQXAXJ9QUe9E7Iyz9wQ7nGj5LSnRgUvShF9XwZpJH7kQBemV9UaNr1DGsKArRuuQ7QTRAVSsuBaFCAIDN1ADiuRRhWCmwCuAbu8hYE6BpUlDD93NMArhwU0xhIqgfJwcYYyq4DdAXMH5i7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