<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99858>99858</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clangd crash with auto template parameter pack expansion
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ahfakt
</td>
</tr>
</table>
<pre>
I have a function with auto template parameter pack and has no reference in current project scope. clangd prints the following trace. I think there needs to be a check for nullptr in there.
```
[~]$ $ pacman -Q --info clang
Name : clang
Version : 18.1.8-1
Description : C language family frontend for LLVM
Architecture : x86_64
URL : https://clang.llvm.org/
Licenses : custom:Apache 2.0 with LLVM Exception
Groups : None
Provides : clang-analyzer=18.1.8 clang-tools-extra=18.1.8
Depends On : llvm-libs gcc compiler-rt
Optional Deps : openmp: OpenMP support in clang with -fopenmp
python: for scan-view and git-clang-format [installed]
llvm: referenced by some clang headers [installed]
Required By : doxygen
Optional For : qt6-tools
Conflicts With : clang-analyzer clang-tools-extra
Replaces : clang-analyzer clang-tools-extra
Installed Size : 209.03 MiB
Packager : Evangelos Foutras <foutrelis@archlinux.org>
Build Date : Sun 30 Jun 2024 11:53:44 AM +03
Install Date : Sun 14 Jul 2024 12:03:45 AM +03
Install Reason : Installed as a dependency for another package
Install Script : No
Validated By : Signature
```
https://clang.llvm.org/doxygen/SemaTemplateVariadic_8cpp_source.html#:~:text=if%20(Instantiation%2D%3Eis,736
```
#0 0x00007d1d7bfc4d90 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/libLLVM.so.18.1+0x7c4d90)
#1 0x00007d1d7bfc1d4d (/usr/lib/libLLVM.so.18.1+0x7c1d4d)
#2 0x00007d1d7b250ae0 (/usr/lib/libc.so.6+0x3cae0)
#3 0x00007d1d84e7d57a clang::LocalInstantiationScope::findInstantiationOf(clang::Decl const*) (/usr/lib/libclang-cpp.so.18.1+0x147d57a)
#4 0x00007d1d84ec8860 clang::Sema::CheckParameterPacksForExpansion(clang::SourceLocation, clang::SourceRange, llvm::ArrayRef<std::pair<llvm::PointerUnion<clang::TemplateTypeParmType const*, clang::NamedDecl*>, clang::SourceLocation>>, clang::MultiLevelTemplateArgumentList const&, bool&, bool&, std::optional<unsigned int>&) (/usr/lib/libclang-cpp.so.18.1+0x14c8860)
#5 0x00007d1d861a0479 (/usr/lib/libclang-cpp.so.18.1+0x27a0479)
#6 0x00007d1d84e76ead (/usr/lib/libclang-cpp.so.18.1+0x1476ead)
#7 0x00007d1d849230f7 (/usr/lib/libclang-cpp.so.18.1+0xf230f7)
#8 0x00007d1d84923328 clang::Sema::AreConstraintExpressionsEqual(clang::NamedDecl const*, clang::Expr const*, clang::Sema::TemplateCompareNewDeclInfo const&, clang::Expr const*) (/usr/lib/libclang-cpp.so.18.1+0xf23328)
#9 0x00007d1d84d26035 (/usr/lib/libclang-cpp.so.18.1+0x1326035)
#10 0x00007d1d84d2644a clang::Sema::CheckOverload(clang::Scope*, clang::FunctionDecl*, clang::LookupResult const&, clang::NamedDecl*&, bool) (/usr/lib/libclang-cpp.so.18.1+0x132644a)
#11 0x00007d1d849810da clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) (/usr/lib/libclang-cpp.so.18.1+0xf810da)
#12 0x00007d1d8498744c clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) (/usr/lib/libclang-cpp.so.18.1+0xf8744c)
#13 0x00007d1d849987a5 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/usr/lib/libclang-cpp.so.18.1+0xf987a5)
#14 0x00007d1d849a400b clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::Sema::SkipBodyInfo*, clang::Sema::FnBodyKind) (/usr/lib/libclang-cpp.so.18.1+0xfa400b)
#15 0x00007d1d8406276f clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/lib/libclang-cpp.so.18.1+0x66276f)
#16 0x00007d1d84064265 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/usr/lib/libclang-cpp.so.18.1+0x664265)
#17 0x00007d1d84064afa clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/usr/lib/libclang-cpp.so.18.1+0x664afa)
#18 0x00007d1d84065056 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/usr/lib/libclang-cpp.so.18.1+0x665056)
#19 0x00007d1d83fd997b clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/usr/lib/libclang-cpp.so.18.1+0x5d997b)
#20 0x00007d1d8406544b clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/libclang-cpp.so.18.1+0x66544b)
#21 0x00007d1d83fb7f8f clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/usr/lib/libclang-cpp.so.18.1+0x5b7f8f)
#22 0x00007d1d83fb90e9 clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/usr/lib/libclang-cpp.so.18.1+0x5b90e9)
#23 0x00007d1d83fd9b2c clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/usr/lib/libclang-cpp.so.18.1+0x5d9b2c)
#24 0x00007d1d8406544b clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/usr/lib/libclang-cpp.so.18.1+0x66544b)
#25 0x00007d1d84065fdb clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/libclang-cpp.so.18.1+0x665fdb)
#26 0x00007d1d83f89ec0 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/libclang-cpp.so.18.1+0x589ec0)
#27 0x00007d1d85a1a7c1 clang::FrontendAction::Execute() (/usr/lib/libclang-cpp.so.18.1+0x201a7c1)
#28 0x0000605d7e700e44 (/usr/bin/clangd+0x57ae44)
#29 0x0000605d7e6fc63c (/usr/bin/clangd+0x57663c)
#30 0x0000605d7e754c59 (/usr/bin/clangd+0x5cec59)
#31 0x00007d1d7b2a6ded (/usr/lib/libc.so.6+0x92ded)
#32 0x00007d1d7b32a0dc (/usr/lib/libc.so.6+0x1160dc)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1z4rjS_jXOjQrKlr_gggtC4H2zJ9nkhNnZyykht0EbIXkkOQN7sb_9lGQ-LAeYYTd19lRtaiZxotajfh61uiULojVbCoBRkN4G6d0Nqc1KqhFZleTV3CxksR3doxV5A0RQWQtqmBToGzMrRGojkYF1xYkBVBFF1mBAoYrQV0REgVZEIyGRghIUCAqICURrpUAYVCn5G1CDNJUV9BHlRCwLVCkmjEZmBaiUnMtvTCyRUYRCH90js2Li1TYqQAKg0MhItLCO0RXQV1RKhUTNeWWUHcoZ9oPwLgjHu-9ZuPvX_Jre_hGkdwFOkP1fEbomAvX-jXo9JkrZ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