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

    <tr>
        <th>Summary</th>
        <td>
            clangd crashes in DeclareAggregateDeductionGuideFromInitList()
        </td>
    </tr>

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

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

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

<pre>
    This problem occurs with both clangd `19.1.0` and f3c408d1726f6a921212faf68085f68bf8533f0c.

My project contains `.cpp` files that include `.hpp` files that are generated during the build. The `.cpp` files are present from the beginning. I was only able to reproduce this crash while the generated `.hpp` were still missing. With all the generated header present, I was not able to reproduce the problem.

The `range-v3` library from the error message below is this one: https://github.com/ericniebler/range-v3/archive/refs/tags/0.12.0.tar.gz.
I can unfortunately not provide more sources.

```
I[18:42:55.200] clangd version 20.0.0git (https://github.com/llvm/llvm-project.git f3c408d1726f6a921212faf68085f68bf8533f0c)
I[18:42:55.200] Features: linux
I[18:42:55.200] argv[0]: /home/myuser/workspace/llvm-project-build/install/bin/clangd
I[18:42:55.200] argv[1]: --background-index
I[18:42:55.200] argv[2]: --header-insertion=never
I[18:42:55.200] argv[3]: --cross-file-rename
I[18:42:55.200] argv[4]: --clang-tidy
I[18:42:55.200] argv[5]: --all-scopes-completion
I[18:42:55.200] argv[6]: -j=16
I[18:42:55.200] argv[7]: --log=verbose
...
V[18:56:47.531] Build dynamic index for header symbols with estimated memory usage of 47815514 bytes
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.    /home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/algorithm/nth_element.hpp:117:44: current parser token ';'
1.    /home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/algorithm/nth_element.hpp:47:1: parsing namespace 'ranges'
2.    /home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/algorithm/nth_element.hpp:106:5 <Spelling=/home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/detail/config.hpp:630:5>: parsing struct/union/class body 'ranges::nth_element_fn'
3.    /home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/algorithm/nth_element.hpp:113:9: parsing function body 'ranges::nth_element_fn::operator()'
4.    /home/myuser/.conan2/p/rangeaf0fd4a9ae478/p/include/range/v3/algorithm/nth_element.hpp:113:9: in compound statement ('{}')
 #0 0x0000564a101b41ff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x7941ff)
 #1 0x0000564a101b1cb4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f1d52307420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x0000564a10b77ee4 clang::Sema::DeclareAggregateDeductionGuideFromInitList(clang::TemplateDecl*, llvm::MutableArrayRef<clang::QualType>, clang::SourceLocation) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x1157ee4)
 #4 0x0000564a113ce766 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>)::'lambda0'(bool)::operator()(bool) const::'lambda'(clang::InitListExpr*)::operator()(clang::InitListExpr*) const SemaInit.cpp:0:0
 #5 0x0000564a113cef77 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>)::'lambda0'(bool)::operator()(bool) const SemaInit.cpp:0:0
 #6 0x0000564a113cfa22 clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x19afa22)
 #7 0x0000564a10f52e20 clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*, clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*, clang::SourceRange, bool, clang::Expr*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x1532e20)
 #8 0x0000564a10f5fabf clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x153fabf)
 #9 0x0000564a10f84d39 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x1564d39)
#10 0x0000564a138a5d9c clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e85d9c)
#11 0x0000564a138bb941 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e9b941)
#12 0x0000564a138be500 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e9e500)
#13 0x0000564a138bea47 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e9ea47)
#14 0x0000564a139720fc clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3f520fc)
#15 0x0000564a13972ad4 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3f52ad4)
#16 0x0000564a13973e39 clang::Parser::ParseCompoundStatementBody(bool) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3f53e39)
#17 0x0000564a13976162 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3f56162)
#18 0x0000564a1388b1ee clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e6b1ee)
#19 0x0000564a1388ae7d clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e6ae7d)
#20 0x0000564a138e0bb6 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3ec0bb6)
#21 0x0000564a138e3aa8 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3ec3aa8)
#22 0x0000564a138ac619 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e8c619)
#23 0x0000564a138732ef clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e532ef)
#24 0x0000564a13874200 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e54200)
#25 0x0000564a1387ddc3 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e5ddc3)
#26 0x0000564a138d9c57 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3eb9c57)
#27 0x0000564a138e2047 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3ec2047)
#28 0x0000564a138bec25 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e9ec25)
#29 0x0000564a1387de74 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e5de74)
#30 0x0000564a1387f6f8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e5f6f8)
#31 0x0000564a1386d94a clang::ParseAST(clang::Sema&, bool, bool) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3e4d94a)
#32 0x0000564a135e4891 clang::FrontendAction::Execute() (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x3bc4891)
#33 0x0000564a11b97cd0 clang::clangd::BackgroundIndex::index(clang::tooling::CompileCommand) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x2177cd0)
#34 0x0000564a11b9914d clang::clangd::BackgroundIndex::indexFileTask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)::'lambda'()::operator()() const Background.cpp:0:0
#35 0x0000564a11ba459f clang::clangd::BackgroundQueue::work(std::function<void ()>) (/home/myuser/workspace/llvm-project-build/install/bin/clangd+0x218459f)
#36 0x0000564a11b90d8d void llvm::detail::UniqueFunctionBase<void>::CallImpl<clang::clangd::BackgroundIndex::BackgroundIndex(clang::clangd::ThreadsafeFS const&, clang::clangd::GlobalCompilationDatabase const&, llvm::unique_function<clang::clangd::BackgroundIndexStorage* (llvm::StringRef)>, clang::clangd::BackgroundIndex::Options)::'lambda0'()>(void*) Background.cpp:0:0
#37 0x0000564a11c4ce16 void* llvm::thread::ThreadProxy<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::'lambda0'()>>(void*) Threading.cpp:0:0
#38 0x00007f1d522fb609 start_thread /build/glibc-LcI20x/glibc-2.31/nptl/pthread_create.c:478:7
#39 0x00007f1d51e07353 __clone /build/glibc-LcI20x/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97:0
[Error - 6:56:50 PM] The Clang Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW81y4ziSfhr6grCCBEmRPPgg_6jXsVXTNWVv7dwcIJiUMAYBDgDa1jz9BkBKJihblnta0xU7HdFdloi__L5MJDKhJNGarQTARZBeBun1GenMWqoLTdcgHkGdlbLaXNyvmUatkiWHBklKO6XRMzNrVEqzRpQTsapQMA-jYhbNwmAeIiIqVMc0CfMqyvC8npMCRzjCNanneZin9Twv6zyN4zqks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