<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/143266>143266</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-21 Crash: Unexpected placeholder builtin type! UNREACHABLE executed at /root/llvm-project/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp:593!
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hyf751175784
</td>
</tr>
</table>
<pre>
### Description
I encountered a crash in Clang-21 when compiling the following code with compilation options:
```cpp
int main() {
int n = 1;
auto h = [&]<int>() { n = 0; };
auto m = [h]<int j>() { h.template operator()<j>(); };
m.template operator()<0>();
return n;
}
```
Options:
```sh
-std=c++11 -pedantic -Wall -Wextra -Wconversion
```
### Clang Version
```sh
$ clang -v
Ubuntu clang version 21.0.0 (++20250501082025+9b1051281e43-1~exp1~20250501082214.882)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-21/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Selected multilib: .;@m64
```
### Command
The compilation command used was:
```sh
clang bug.cpp -std=c++11 -pedantic -Wall -Wextra -Wconversion -c -o bug.o
```
### Error Message
```sh
<source>:3:17: warning: explicit template parameter list for lambdas is a C++20 extension [-Wc++20-extensions]
3 | auto h = [&]<int>() { n = 0; };
| ^
<source>:4:17: warning: explicit template parameter list for lambdas is a C++20 extension [-Wc++20-extensions]
4 | auto m = [h]<int j>() { h.template operator()<j>(); };
| ^
Unexpected placeholder builtin type!
UNREACHABLE executed at /root/llvm-project/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp:593!
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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++11 -pedantic -Wall -Wextra -Wconversion <source>
1. <eof> parser at end of file
2. <source>:1:5: LLVM IR generation of declaration 'main'
3. <source>:1:5: Generating code for declaration 'main'
#0 0x0000000003fe10d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fe10d8)
#1 0x0000000003fded64 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fded64)
#2 0x0000000003f23ac8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000793f7c242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000793f7c2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000793f7c242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x0000793f7c2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000000003f2f20a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f2f20a)
#8 0x000000000460095f clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x460095f)
#9 0x00000000048943ff clang::CodeGen::CodeGenTypes::arrangeLLVMFunctionInfo(clang::CanQual<clang::Type>, clang::CodeGen::FnInfoOpts, llvm::ArrayRef<clang::CanQual<clang::Type>>, clang::FunctionType::ExtInfo, llvm::ArrayRef<clang::FunctionType::ExtParameterInfo>, clang::CodeGen::RequiredArgs) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48943ff)
#10 0x000000000489680e arrangeLLVMFunctionInfo(clang::CodeGen::CodeGenTypes&, bool, llvm::SmallVectorImpl<clang::CanQual<clang::Type>>&, clang::CanQual<clang::FunctionProtoType>) CGCall.cpp:0:0
#11 0x0000000004899b6c clang::CodeGen::CodeGenTypes::arrangeCXXMethodType(clang::CXXRecordDecl const*, clang::FunctionProtoType const*, clang::CXXMethodDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4899b6c)
#12 0x0000000004899d6b clang::CodeGen::CodeGenTypes::arrangeCXXMethodDeclaration(clang::CXXMethodDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4899d6b)
#13 0x00000000043752a1 clang::CodeGen::CodeGenFunction::EmitCXXMemberOrOperatorMemberCallExpr(clang::CallExpr const*, clang::CXXMethodDecl const*, clang::CodeGen::ReturnValueSlot, bool, clang::NestedNameSpecifier*, bool, clang::Expr const*, llvm::CallBase**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43752a1)
#14 0x0000000004376551 clang::CodeGen::CodeGenFunction::EmitCXXMemberCallExpr(clang::CXXMemberCallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::CallBase**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4376551)
#15 0x0000000004350b5d clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::CallBase**) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4350b5d)
#16 0x00000000043c3844 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#17 0x00000000043b6670 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#18 0x00000000043bc5ec clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43bc5ec)
#19 0x00000000043270ae clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43270ae)
#20 0x000000000434e93d clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x434e93d)
#21 0x00000000044c5b32 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44c5b32)
#22 0x00000000044cdbec clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44cdbec)
#23 0x00000000045339ce clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45339ce)
#24 0x0000000004546ce4 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4546ce4)
#25 0x00000000045b115d clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45b115d)
#26 0x00000000045ac174 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45ac174)
#27 0x00000000045ac823 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45ac823)
#28 0x00000000045b7343 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#29 0x000000000499c086 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#30 0x000000000498bb64 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x498bb64)
#31 0x000000000668f424 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x668f424)
#32 0x0000000004998218 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4998218)
#33 0x0000000004c921a5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c921a5)
#34 0x0000000004c0f4ae clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c0f4ae)
#35 0x0000000004d84509 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d84509)
#36 0x0000000000dbc45f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdbc45f)
#37 0x0000000000db306a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#38 0x00000000049ff269 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
#39 0x0000000003f23f64 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f23f64)
#40 0x00000000049ff87f 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
#41 0x00000000049c13cd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49c13cd)
#42 0x00000000049c245e 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+++0x49c245e)
#43 0x00000000049ca555 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49ca555)
#44 0x0000000000db896f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdb896f)
#45 0x0000000000c3bba4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc3bba4)
#46 0x0000793f7c229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#47 0x0000793f7c229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#48 0x0000000000db2b15 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdb2b15)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
The issue can also be reproduced on Compiler Explorer:https://godbolt.org/z/vETxYq9f9
Please let me know if you need any more details.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkW11z27iS_TX0C4oqEvwQ-eAHmrZzM5WZZGNPMvvkAsGmxBsQ4AVAR96H-9u3AFKiSEtO5LGyt2qnPCkJBBrnnG40miRElKpXHODSia6c6PqCdHot5OX6qVpGvr-Mlkl4UYjy6dLBQf-HrkFRWbe6FtzxsvcIOBUd1yChRARRSdQa1RzljPCVi330fQ0cUdG0Nav5Cuk1oEowJr6bb1SUgL7Xej30IMYsEta6coLM8TIn9vo_2raOl9Vco4bU3MGJg1PkLK8cL0MIIXOBIye4Rr4T2EbSaYHWtsnQw7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