<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/134471>134471</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Crash on CTAD for alias template involving default arguments
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          MagentaTreehouse
      </td>
    </tr>
</table>

<pre>
    ```c++
template <class>
struct A {};

template <class T = int, class U = T>
using AA = A<U>;

AA a{};
```

See https://compiler-explorer.com/z/fE9MGanjd.

Assertion:
```console
clang++: /root/llvm-project/clang/lib/AST/ASTContext.cpp:6544:
clang::QualType clang::ASTContext::getDeducedTemplateSpecializationTypeInternal(clang::TemplateName, clang::QualType, bool, clang::QualType) const:
Assertion `ID == TempID && "ID does not match"' failed.
```

<details>

<summary>Stack dump</summary>

```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.      <source>:7:7: current parser token ';'
 #0 0x0000000003eaa8c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eaa8c8)
 #1 0x0000000003ea8554 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ea8554)
 #2 0x0000000003ded098 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000071b807642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000071b8076969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000071b807642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000071b8076287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000071b80762871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000071b807639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000073a412c clang::ASTContext::getDeducedTemplateSpecializationTypeInternal(clang::TemplateName, clang::QualType, bool, clang::QualType) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x73a412c)
#10 0x00000000073f11a3 clang::ASTContext::getDeducedTemplateSpecializationType(clang::TemplateName, clang::QualType, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x73f11a3)
#11 0x0000000006fc3765 clang::TreeTransform<(anonymous namespace)::SubstituteDeducedTypeTransform>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateDeduction.cpp:0:0
#12 0x0000000006fdf18d clang::TreeTransform<(anonymous namespace)::SubstituteDeducedTypeTransform>::TransformElaboratedType(clang::TypeLocBuilder&, clang::ElaboratedTypeLoc) SemaTemplateDeduction.cpp:0:0
#13 0x0000000006fc2a73 clang::TreeTransform<(anonymous namespace)::SubstituteDeducedTypeTransform>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) SemaTemplateDeduction.cpp:0:0
#14 0x0000000006fc45b2 clang::TreeTransform<(anonymous namespace)::SubstituteDeducedTypeTransform>::TransformType(clang::TypeSourceInfo*) SemaTemplateDeduction.cpp:0:0
#15 0x0000000006fc47b0 clang::TreeTransform<(anonymous namespace)::SubstituteDeducedTypeTransform>::TransformType(clang::QualType) SemaTemplateDeduction.cpp:0:0
#16 0x0000000006fc5a24 clang::Sema::SubstAutoType(clang::QualType, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6fc5a24)
#17 0x0000000006becf1d clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6becf1d)
#18 0x000000000686b5ed clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*, clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*, clang::SourceRange, bool, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x686b5ed)
#19 0x00000000068703f7 clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x68703f7)
#20 0x00000000068913a2 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x68913a2)
#21 0x0000000006518a95 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6518a95)
#22 0x00000000065280b9 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65280b9)
#23 0x00000000064e6bae clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64e6bae)
#24 0x00000000064e7369 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64e7369)
#25 0x00000000064ef173 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64ef173)
#26 0x00000000064f008d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64f008d)
#27 0x00000000064e201a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64e201a)
#28 0x0000000004843468 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4843468)
#29 0x0000000004b31f05 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b31f05)
#30 0x0000000004ab3d9e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ab3d9e)
#31 0x0000000004c2211e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c2211e)
#32 0x0000000000d5fb1f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd5fb1f)
#33 0x0000000000d572da ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#34 0x00000000048a8db9 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
#35 0x0000000003ded534 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ded534)
#36 0x00000000048a93cf 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
#37 0x000000000486be6d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x486be6d)
#38 0x000000000486cefe 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+++0x486cefe)
#39 0x0000000004874605 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4874605)
#40 0x0000000000d5c918 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd5c918)
#41 0x0000000000c22cf4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc22cf4)
#42 0x000071b807629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#43 0x000071b807629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#44 0x0000000000d56d85 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd56d85)
```

</details>
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkmk1z2zjSgH8NfEHJRYLfBx8YyZrX8yabbOzJVQWCoMwJCXAB0GPPr98CQIkEJTlRjeXZ2k3ZKQsfje6nG42mCCxlvWWU3oDoA4hWV7hXj1zcfMJbyhR-EJQ-8l7Sq4KXLzcg9uwPAeiD_vFyRduuwYpCECxJg6UEwS3wcqlETxTMIUg-gGQFAj322HD4AEGwgjVTAC2hbfrNND1YSb2s2RbmuWnLQbD8Tbfv5OU5xM4SOw1t9z2l8FGpToIgB2gN0JrwtqsbKhb0uWu4oOKa8Bag9Z8Aravb7NMvmP1eXg_CpaRC1Zzp2RPZhDPJGwq8nDSYbQcWQQ4BWgvOFUDrpnlqF53gv1OiPw7j1k1dALTO7x_s_0vOFH1W16TrQJDHURjalezwIAdB_s8eNw8vHYWTtnGm_bylak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