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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Assertion `!hasUninstantiatedDefaultArg() && "Default argument is not yet instantiated!"` failed
        </td>
    </tr>

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

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

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

<pre>
    Goes back to clang-16: https://godbolt.org/z/8TYcah3rs

Test Input:

```c++
template <class T> struct A
{
  template <class U>
  A(U = 42);
};

template <typename>
struct B: A<int>
{
  using A::A;
};

B b(24);
```

Stack Dump:

```c++
clang++: /root/llvm-project/clang/lib/Sema/SemaTemplateDeductionGuide.cpp:382: clang::NamedDecl* {anonymous}::ConvertConstructorToDeductionGuideTransform::transformConstructor(clang::FunctionTemplateDecl*, clang::CXXConstructorDecl*): Assertion `Depth || cast<ClassTemplateSpecializationDecl>(FTD->getDeclContext()) ->isExplicitSpecialization()`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 <source>
1.      <source>:13:8: current parser token ';'
 #0 0x0000000003e9fee8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e9fee8)
 #1 0x0000000003e9db74 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e9db74)
 #2 0x0000000003de2f18 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000070ab83e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000070ab83e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000070ab83e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000070ab83e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000070ab83e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000070ab83e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x0000000007021096 (anonymous namespace)::ConvertConstructorToDeductionGuideTransform::transformConstructor(clang::FunctionTemplateDecl*, clang::CXXConstructorDecl*) SemaTemplateDeductionGuide.cpp:0:0
#10 0x0000000007023b5a clang::Sema::DeclareImplicitDeductionGuides(clang::TemplateDecl*, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7023b5a)
#11 0x0000000006c05d5f LookupDirect(clang::Sema&, clang::LookupResult&, clang::DeclContext const*) SemaLookup.cpp:0:0
#12 0x0000000006bf0ce2 clang::Sema::LookupQualifiedName(clang::LookupResult&, clang::DeclContext*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6bf0ce2)
#13 0x0000000006bcf1de clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6bcf1de)
#14 0x000000000684ca6d clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*, clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*, clang::SourceRange, bool, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x684ca6d)
#15 0x0000000006851877 clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6851877)
#16 0x0000000006872862 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6872862)
#17 0x00000000064fa2f9 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64fa2f9)
#18 0x0000000006509549 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+++0x6509549)
#19 0x00000000064c85ce clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64c85ce)
#20 0x00000000064c8d89 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64c8d89)
#21 0x00000000064d0653 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64d0653)
#22 0x00000000064d156d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64d156d)
#23 0x00000000064c3aba clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64c3aba)
#24 0x00000000048325b8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48325b8)
#25 0x0000000004b1ff05 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b1ff05)
#26 0x0000000004aa1bbe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4aa1bbe)
#27 0x0000000004c1027e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c1027e)
#28 0x0000000000d5a10f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd5a10f)
#29 0x0000000000d518ca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x0000000004897c99 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
#31 0x0000000003de33b4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3de33b4)
#32 0x00000000048982af 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
#33 0x000000000485ad1d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x485ad1d)
#34 0x000000000485bdae 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+++0x485bdae)
#35 0x0000000004863485 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4863485)
#36 0x0000000000d56f08 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd56f08)
#37 0x0000000000c1dcc4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc1dcc4)
#38 0x000070ab83e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#39 0x000070ab83e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#40 0x0000000000d51375 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd51375)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWl9z46iW_zTkhbJLQv8f8uDYcW9me3Z6O5mu2ScXQshmWwZdQBlnPv0tQLaE7KQnt-KuW3W73BVbnL-_czgcEFgptuWU3oLkDiSrG9zpnZC3Xzu1CwMURTelqF5uPwmqYInJd6gFJA3m21mYgmgBd1q3CkQLgNYArbeiKkWj50JuAVr_BdA6f_o_gneRVCBYgGDxRJWGD7zttOGxj0AauA8B6M58goWm-7bBmkIQLUmDlYJPILqHSsuOaGiZMkMH4Tnl7yC6t0MLgPLfIYhWMEYAFSC6s3yr_ouvRb-0lOM9dcy9ojvj4AJES8a1Gziq7RTjWzNkPotz0XewBChH8aD36KQbf9QGylW3b9-CweLc_4oWEKC1FEIDtG6a5_2sleL_KTE_e7p1w0qA1o90j_s_T72HK1p1RDPBP3WsonPSGrVRjoxUx2wd-R-8p9WKkgagBQTZHeaCv-xFp6xrhmIp-DOVeim4g0jIJ-ELf5KYq1rIvWPQx58jFoDykdJ1xy33YKvVD9BybNryjz9GEk40hY2QUlQaERCkwYq2egdBtgTZEhKsNIiWS5MYR_mPLSUMN-wvbFispOgeoHz9tJqB6H5LtXm2FFzTgwYoN0pQAc0YU_eHtmGEaV9IT5UGNWYNreYuoF8-3y8e76Hqyj3TEMOy20JJ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