<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113803>113803</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-20 : Assertion `!DT.isNull() && "Undeduced types shouldn't reach here."' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
iamanonymouscs
</td>
</tr>
</table>
<pre>
### Description
I encountered a crash in Clang-20 when compiling the following code snippet:
```cpp
char myfunc();
template<typename T> T my_templated_func();
template<> auto my_templated_func()
{
return myfunc();
}
```
### Error Message
The compilation fails with the following assertion error:
```sh
clang++: /root/llvm-project/clang/lib/CodeGen/CGDebugInfo.cpp:3681: clang::QualType UnwrapTypeForDebugInfo(clang::QualType, const clang::ASTContext&): Assertion !DT.isNull() && "Undeduced types shouldn't reach here." failed.
```
### Command
```sh
clang++ bug.cpp -O3 -ffast-math -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address -c -o bug.o
clang++: /root/llvm-project/clang/lib/CodeGen/CGDebugInfo.cpp:3681: clang::QualType UnwrapTypeForDebugInfo(clang::QualType, const clang::ASTContext&): Assertion `!DT.isNull() && "Undeduced types shouldn't reach here."' 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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O3 -ffast-math -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address <source>
1. <eof> parser at end of file
2. <source>:5:18: LLVM IR generation of declaration 'my_templated_func'
3. <source>:5:18: Generating code for declaration 'my_templated_func'
#0 0x0000000003bd52c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bd52c8)
#1 0x0000000003bd2fcc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bd2fcc)
#2 0x0000000003b209a8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007032d0e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007032d0e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007032d0e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007032d0e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007032d0e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007032d0e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000003e86e5b UnwrapTypeForDebugInfo(clang::QualType, clang::ASTContext const&) CGDebugInfo.cpp:0:0
#10 0x0000000003ecf54c clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ecf54c)
#11 0x0000000003ed5a01 clang::CodeGen::CGDebugInfo::CollectTemplateParams(std::optional<clang::CodeGen::CGDebugInfo::TemplateArgs>, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ed5a01)
#12 0x0000000003ee2be2 clang::CodeGen::CGDebugInfo::collectFunctionDeclProps(clang::GlobalDecl, llvm::DIFile*, llvm::StringRef&, llvm::StringRef&, llvm::DIScope*&, llvm::MDTupleTypedArrayWrapper<llvm::DINode>&, llvm::DINode::DIFlags&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ee2be2)
#13 0x0000000003ee3667 clang::CodeGen::CGDebugInfo::emitFunctionStart(clang::GlobalDecl, clang::SourceLocation, clang::SourceLocation, clang::QualType, llvm::Function*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ee3667)
#14 0x0000000003fb4bd6 clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, clang::QualType, llvm::Function*, clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::FunctionArgList const&, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fb4bd6)
#15 0x0000000003fba589 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fba589)
#16 0x00000000040230aa clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40230aa)
#17 0x000000000401dfd5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x401dfd5)
#18 0x000000000401e3bb clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x401e3bb)
#19 0x00000000040287b3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#20 0x000000000454d106 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#21 0x000000000453de38 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453de38)
#22 0x00000000066a1884 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66a1884)
#23 0x000000000454acb8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x454acb8)
#24 0x00000000048045d9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48045d9)
#25 0x00000000047837be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47837be)
#26 0x00000000048e9cee clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48e9cee)
#27 0x0000000000ce2b8f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce2b8f)
#28 0x0000000000cda84a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#29 0x000000000458e0c9 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
#30 0x0000000003b20e54 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b20e54)
#31 0x000000000458e6bf 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
#32 0x000000000455487d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x455487d)
#33 0x000000000455596d 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+++0x455596d)
#34 0x000000000455cd25 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x455cd25)
#35 0x0000000000cdfa29 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdfa29)
#36 0x0000000000baddb4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbaddb4)
#37 0x00007032d0e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#38 0x00007032d0e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#39 0x0000000000cda2fe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcda2fe)
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/r9hhKz8zq
### Steps to Reproduce:
Compile the provided code snippet using Clang-20.
Observe the crash and assertion failure.
### Additional Information
Please let me know if you need any more details.
Thank you for your assistance.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWt1y2ziyfhr6BkUVCVIUdeELRbJzPCeZ5MSemUsVCDQlHoMAFwD9k6ffAkDJhCJ57Kyd2tqd0sQSfhpff91oNMgmWjcbAXAeTT9E09UZ6c1WqvOGtERI8djKXlN9Vkn2eB7hzH_QCjRVTWcaKaJkFSWLKwSCyl4YUMAQQVQRvUWNQEtOxCbGCbrfgkBUtl3DG7FBZguolpzLe_uLSgZIi6brwETZwssc_i0S_6Fd51sQ3RKF2se6FzTCZYTnUfZh6Br-GGg7TgxE2dI8diBIC-gmyi7QDWof17tetn6ZCDuR9EaenDtMnO1EIKTA9EqcAjlbHdUwaNxzjS6Ukgp9Bq3JBnzvzRYGLom1AapJwzW6b8z2gFiiNSg3BKyUJ253a-qtb6DWThH-YD_ZAkX4UklpInzJ-V0bd0r-P1D7cxh3yZsqwpdLyeAjCPvt4wqqfnMlajmxlsoWWVGmVpSfkS2ibPF_PeE3jx2gP8S9Ip39einVfmKEyyODI7xEVAptxpIW1zdLKQw8mAgXj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