<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112153>112153</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang++] undeduced type in IR-generation UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:267!
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:codegen,
crash-on-invalid,
regression:16,
clang:frontend:fuzzer
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yijan4845
</td>
</tr>
</table>
<pre>
**This testcase is generated by a fuzzer.**
Compiler Explorer: [https://godbolt.org/z/WYveMhMK3](https://godbolt.org/z/WYveMhMK3)
This invalid code will crash on both Clang Trunk and Clang Assertion Trunk, it seems that this goes back to clang-16:
```cpp
template<typename T> void g(T t) {
typename T::X x = x;
}
struct A { template<typename T> struct X { X(T); }; };
void h(A a) { g(a); }
```
The stack dump and error message are similar to [33335](https://github.com/llvm/llvm-project/issues/33335) and [55872](https://github.com/llvm/llvm-project/issues/55872).
Stack dump:
```
undeduced type in IR-generation
UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:267!
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 <source>
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. <source>:1:27: Generating code for declaration 'g'
#0 0x0000000003baa6d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3baa6d8)
#1 0x0000000003ba839c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ba839c)
#2 0x0000000003af55f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000070fecc242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000070fecc2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000070fecc242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000070fecc2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000000003b00eca (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b00eca)
#8 0x0000000003f7ba1a clang::CodeGen::CodeGenFunction::getEvaluationKind(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f7ba1a)
#9 0x00000000042e0a18 clang::CodeGen::CodeGenFunction::EmitCallArg(clang::CodeGen::CallArgList&, clang::Expr const*, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42e0a18)
#10 0x00000000042eb507 clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, clang::CodeGen::CodeGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* const, clang::Stmt const* const>>, clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, clang::CodeGen::CodeGenFunction::EvaluationOrder) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42eb507)
#11 0x000000000430f63e clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall(clang::CXXConstructorDecl const*, clang::CXXCtorType, bool, bool, clang::CodeGen::AggValueSlot, clang::CXXConstructExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x430f63e)
#12 0x00000000043a93bf clang::CodeGen::CodeGenFunction::EmitCXXConstructExpr(clang::CXXConstructExpr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43a93bf)
#13 0x000000000438d38a (anonymous namespace)::AggExprEmitter::VisitCXXConstructExpr(clang::CXXConstructExpr const*) CGExprAgg.cpp:0:0
#14 0x0000000004399431 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#15 0x000000000439cd34 (anonymous namespace)::AggExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprAgg.cpp:0:0
#16 0x0000000004399401 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#17 0x000000000439a090 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x439a090)
#18 0x000000000432c542 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x432c542)
#19 0x0000000004338901 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4338901)
#20 0x0000000004338ec6 clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#21 0x0000000004339116 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4339116)
#22 0x0000000003efe587 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3efe587)
#23 0x0000000003f15189 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f15189)
#24 0x0000000003f0ce35 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f0ce35)
#25 0x0000000003f14ba4 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f14ba4)
#26 0x0000000003f7d044 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f7d044)
#27 0x0000000003f8f02c clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f8f02c)
#28 0x0000000003ff7bfa clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ff7bfa)
#29 0x0000000003ff28d5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ff28d5)
#30 0x0000000003ffe94d clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ffe94d)
#31 0x0000000004000a63 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4000a63)
#32 0x00000000045047ce (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#33 0x0000000004502425 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4502425)
#34 0x000000000664064c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x664064c)
#35 0x0000000004502bd8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4502bd8)
#36 0x00000000047bc4d9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47bc4d9)
#37 0x000000000473b07e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x473b07e)
#38 0x00000000048a204e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48a204e)
#39 0x0000000000cdb81f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdb81f)
#40 0x0000000000cd352a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#41 0x00000000045468a9 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
#42 0x0000000003af5aa4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3af5aa4)
#43 0x0000000004546e9f 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
#44 0x000000000450c7dd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x450c7dd)
#45 0x000000000450d8cd 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+++0x450d8cd)
#46 0x00000000045151f5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45151f5)
#47 0x0000000000cd86ef clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd86ef)
#48 0x0000000000ba7c44 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xba7c44)
#49 0x000070fecc229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#50 0x000070fecc229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#51 0x0000000000cd2fde _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd2fde)
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/eJzkW1Fzm7gW_jXkRWMPSGDgIQ_ESbrdbe_2Ntlu75NHCIHZgsRIInX66-9IwjHCdlpn487euZ22ceDo6Ps-HR0dhIylrCtG6aUXXXnR9QXu1ZqLy8f6L8zCJIwucl48Xnow82B2v64lUFQqgiUFtQQVZVRgRQuQPwIMyv7bNyrm1tjzrz1_-H_J265uqAA3m67hggoPZcCLrtZKddJDmQdvPXhb8SLnjZpzUXnw9psHb__8zwN9v37_G_Kiaw8mP24O03H3BnfNHnBTF4DwgoKvddMAIrBcA85AztUaLBvMKnAvevYFYFYMv2dSUqFqzuwdDy5BrYCktJVArbECSvuuOJUgx-QLUBwQ3XAWLDRQC2Lh27-k6-wVRduuwYp6aKkeO8pwS8G9h27AA68LUHkwuQfKgynw4ivbAoCxYeah7DPYAA9dg42HBhsvvrYfpBI9USDTzcHRvgarz8bqs-5Ty4augPbz9MN6NLjWHkwygAdcBiYeNXG5uvpTIJWWp-jbzqhLheACtFRKXFGABQWybusGC62gF10hhFB0cNRrte7zOeGtB2-b5mH7Y9YJ_hclyoO3tZQ9lR68tU5ganr0oqsoSmL4d51aJzCdjxnePbHbjfohPXpW0KIntDDDCWo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