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

    <tr>
        <th>Summary</th>
        <td>
            clangd crash on c++ template code accepted by clang
        </td>
    </tr>

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

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

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

<pre>
    minimal reproducer:
```cpp
#include <concepts>

template <typename Ret,
          std::convertible_to<Ret (*)()> Default = decltype([] {
 return Ret();
          })>
void func() {}
```

backtrace:
```
$ clangd --check=bug.cc -log=verbose
I[15:21:45.938] clangd version 19.0.0git (https://github.com/llvm/llvm-project.git da70f2cdcde8cb96e75ce0236db1fb5353407a69)
I[15:21:45.938] Features: linux+debug+grpc
I[15:21:45.938] argv[0]: clangd
I[15:21:45.938] argv[1]: --check=bug.cc
I[15:21:45.938] argv[2]: -log=verbose
I[15:21:45.938] Entering check mode (no LSP server)
I[15:21:45.939] Loading compilation database...
I[15:21:45.941] Loaded compilation database from compile_flags.txt
I[15:21:45.942] Compile command from CDB is: clang-tool -std=gnu++2a -x c++ -- /usrlocal/zorktree-dev/bug.cc
I[15:21:45.943] internal (cc1) args are: -cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -disable-free -clear-ast-before-backend -main-file-name bug.cc -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/usrlocal -fcoverage-compilation-dir=/usrlocal -std=gnu++2a -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -no-round-trip-args -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ bug.cc
I[15:21:45.943] Building preamble...
I[15:21:46.075] Built preamble of size 777436 for file /usr/local/bug.cc version null in 0.13 seconds
I[15:21:46.075] Indexing headers...
V[15:21:46.083] indexed preamble AST for /usr/local/bug.cc version null:
  symbol slab: 965 symbols, 289536 bytes
  ref slab: 0 symbols, 0 refs, 128 bytes
  relations slab: 110 relations, 2200 bytes
V[15:21:46.089] Build dynamic index for header symbols with estimated memory usage of 1643652 bytes
I[15:21:46.089] Building AST...
I[15:21:46.098] Indexing AST...
V[15:21:46.098] indexed file AST for /usr/local/bug.cc version null:
  symbol slab: 1 symbols, 4448 bytes
  ref slab: 1 symbols, 1 refs, 4248 bytes
  relations slab: 0 relations, 24 bytes
V[15:21:46.098] Build dynamic index for main-file symbols with estimated memory usage of 11520 bytes
I[15:21:46.098] Building inlay hints
I[15:21:46.098] Building semantic highlighting
V[15:21:46.098]  2:9-2:10 Bracket 0
V[15:21:46.098] 2:19-2:22 TemplateParameter 16387
V[15:21:46.098]  3:10-3:13 Namespace 131584
V[15:21:46.098]  3:29-3:30 Bracket 0
V[15:21:46.098]  3:30-3:33 TemplateParameter 16384
V[15:21:46.098]  3:39-3:40 Bracket 0
V[15:21:46.098]  3:41-3:48 TemplateParameter 16387
V[15:21:46.098] 4:21-4:24 TemplateParameter 16384
V[15:21:46.098]  5:12-5:13 Bracket 0
V[15:21:46.098]  6:5-6:9 Function 131075
I[15:21:46.098] Testing features at each token (may be slow in large files)
V[15:21:46.098]   0:0 #
V[15:21:46.099]     definition: 1
V[15:21:46.099]     hover: true
V[15:21:46.099]     documentHighlight: 0
V[15:21:46.099]   0:1 include
V[15:21:46.099]     definition: 1
V[15:21:46.099]     hover: true
V[15:21:46.099]     documentHighlight: 0
V[15:21:46.099]   0:9 <
V[15:21:46.099]     definition: 1
V[15:21:46.099]     hover: true
V[15:21:46.099]     documentHighlight: 0
V[15:21:46.099]   0:10 concepts
V[15:21:46.099]     definition: 1
V[15:21:46.099]     hover: true
V[15:21:46.099]     documentHighlight: 0
V[15:21:46.099]   0:18 >
V[15:21:46.099]     definition: 1
V[15:21:46.099]     hover: true
V[15:21:46.099]     documentHighlight: 0
V[15:21:46.099]   2:0 template
V[15:21:46.099]     definition: 1
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: clangd --check=bug.cc -log=verbose
 #0 0x0000000001580c3c PrintStackTraceSignalHandler(void*) (.llvm.11471844361491396420) Signals.cpp:0:0
 #1 0x000000000158184b SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fda2e7901a0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x131a0)
 #3 0x00000000016d06b1 clang::DeclarationName::print(llvm::raw_ostream&, clang::PrintingPolicy const&) const (clangd+0x16d06b1)
 #4 0x00000000016d2bce clang::DeclarationNameInfo::printName(llvm::raw_ostream&, clang::PrintingPolicy) const (clangd+0x16d2bce)
 #5 0x0000000001613f59 clang::ConceptReference::print(llvm::raw_ostream&, clang::PrintingPolicy const&) const (clangd+0x1613f59)
 #6 0x0000000001708c08 (anonymous namespace)::DeclPrinter::VisitTemplateTypeParmDecl(clang::TemplateTypeParmDecl const*) DeclPrinter.cpp:0:0
 #7 0x0000000001707b7c (anonymous namespace)::DeclPrinter::printTemplateParameters(clang::TemplateParameterList const*, bool) (.llvm.16411287656893373907) DeclPrinter.cpp:0:0
 #8 0x0000000001709321 (anonymous namespace)::DeclPrinter::VisitTemplateDecl(clang::TemplateDecl const*) DeclPrinter.cpp:0:0
 #9 0x0000000001712941 (anonymous namespace)::DeclPrinter::VisitFunctionTemplateDecl(clang::FunctionTemplateDecl*) DeclPrinter.cpp:0:0
#10 0x00000000017078b6 clang::Decl::print(llvm::raw_ostream&, clang::PrintingPolicy const&, unsigned int, bool) const (clangd+0x17078b6)
#11 0x0000000002bdb9fb clang::clangd::(anonymous namespace)::getHoverContents(clang::NamedDecl const*, clang::PrintingPolicy const&, clang::clangd::SymbolIndex const*, clang::syntax::TokenBuffer const&) Hover.cpp:0:0
#12 0x0000000002bd7411 clang::clangd::getHover(clang::clangd::ParsedAST&, clang::clangd::Position, clang::format::FormatStyle const&, clang::clangd::SymbolIndex const*) (clangd+0x2bd7411)
#13 0x00000000029500f0 clang::clangd::check(llvm::StringRef, clang::clangd::ThreadsafeFS const&, clang::clangd::ClangdLSPServer::Options const&) (clangd+0x29500f0)
#14 0x0000000002937cf5 clang::clangd::clangdMain(int, char**) (clangd+0x2937cf5)
#15 0x00007fda2d98ad0a __libc_start_main ./csu/../csu/libc-start.c:308:16
#16 0x000000000133633a _start (clangd+0x133633a)
Segmentation fault (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWVtv4rr2_zTpi2UU27k-9IHC8J-RZv9PNVT7PCLHWQneTWxkO52yP_2RHaDAFIbp2TrSVBWEZF1-62Yvr3BrZasA7qP0IUrnd3xwa23u_9LQrbV4vqt0vb3vpZI975CBjdH1IMBEbBrF8yieRlk8_ovNZneHMqlEN9SAIjYTWgnYOBuxT7vH4dNBv-m4CyRuuwHFe0DfwEV0NhKgw591tdfGpkKrFzBOVh2snI7Y7Bs4FNEiotOIluGijNgnNIeGD51DEZujGkTn5funwUAU5Q87DQbcYNSodeR9ONcd5fNR6PjgRcsaNYMSI0OQlc_PHHFsZsXFszNcwI_-2jsrQaLjqq0RxmIN4jli82poJ0Ig3Ok2YvMXMJW2MNJ_idIHkkZsSknEpkk6KVnhrdrJeAFjpVaIlJN4Ercy-Gft3MZ6AHQR0UUr3XqoJkL3EV103cv-C2-M_guEm3iumudxQ0UtaihEVWaQpwJiyrK6Ik2VspQlcc6z0jvnKq4FcDcY8OpRJ9XwGtGHGqqhjehDazbiOjc37UuUPsRROvcCRiNvYiE7lnOn3sRM98y_EIBPyoGRqkVBH-q1T39aKI2-Lh-RBfMC5pq3Si_kq-Z1kKH7jey486GsueMVtzCZTC4xJ2TPDPW7vKgxut89gVXT8dZO3Ku7KM87AM1Gcs_Wc1WPMmbz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