<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110848>110848</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang trunk crashes on invalid code involving incomplete requires-clauses
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
crash-on-invalid
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zyn0217
</td>
</tr>
</table>
<pre>
When I'm typing the requires expression in the following code, clang crashes in the error recovery that in turn causes clangd to crash:
```cpp
template <typename T> requires (sizeof
struct A {
template <typename... Ts>
A(T val, Ts... tail) {}
};
A b(42);
```
https://godbolt.org/z/zzxs74hWx
Stacktrace (w/ assertion build)
```txt
#9 0x000000000725feac clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool, bool, clang::QualType, clang::Expr::Classification, llvm::function_ref<bool (llvm::ArrayRef<clang::QualType>)>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x725feac)
#10 0x0000000007054eae clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, clang::CallExpr::ADLCallKind, clang::OverloadCandidateParamOrder, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7054eae)
#11 0x0000000006e0c8c6 ResolveConstructorOverload(clang::Sema&, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, clang::QualType, clang::DeclContextLookupResult, clang::OverloadCandidate*&, bool, bool, bool, bool, bool, bool) SemaInit.cpp:0:0
#12 0x0000000006e198e0 TryConstructorInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType, clang::QualType, clang::InitializationSequence&, bool, bool) SemaInit.cpp:0:0
#13 0x0000000006e22422 clang::InitializationSequence::InitializeFrom(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e22422)
#14 0x00000000069c0ae7 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69c0ae7)
#15 0x0000000006643fe1 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6643fe1)
#16 0x0000000006653089 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+++0x6653089)
#17 0x0000000006611f8e clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6611f8e)
#18 0x000000000661274e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x661274e)
#19 0x0000000006619ee3 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6619ee3)
#20 0x000000000661adcd clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x661adcd)
#21 0x000000000660d2ea clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x660d2ea
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMmF9v4rgWwD-NeYlAiRNI8sBDCuWquh21tyDN45VxTsA7xs7YDgP99Cs7_EkCLbO7bbVVIYl9fP78zoltTLRmKwEwRsM7NJz2SGXWUo1f98LHQdxbynw__r4G4T0gHG88sy-ZWHlmDZ6CnxVToD3YlQq0ZlJ4TLiuQnIuf1lBKnNAeOJRTuyTInoN-igGSknlKaByC2rvmTUxrqtSwqOk0qDrcblnZD0WhRnyp8g_fo_8-p-WZd1iYFNyYsBD4cTsSxBkA94ChfdndxFONHsFWdQjtFEVNV7mofiubvG8a1oGg4G30Ci8PwplCCcLb0u4jW-hbb8hjCOcOlXx9OBjPEXhXdPrzFsinEQY4fTcc4ykKbg2ptQ2ZDxDeLaS-VJyM5BqhfDs1X5edzqO1t93zUFzQ-gPowgFG-kvhGce0RqUsflZVozn1m7bqNmZQwsOU8_f-ce_GA8LILROg_UkzOawIfXdFPKKwuLAKlOragPCaISThvisEtSaPopNgXKEs1NN1FJdJY9MmwdRyIMk59tNLZgpRfYvUKBw0hh-vyuVFQ3vO3qP1k9WRx0BfYrm7GBeuTG1fTdgKSVvXhsK_lcRvtiX0Gl2Hrm7CbevWMEosUrb0RQH9_6vXERWvU3arXBPNm28af1txyE8k6VBeEblpmQcVB92JZcKlG2z4_unUtB9oyrxA-HZkoljN8J39b-_O2T-XCs4DPxWafjDCAhcL40sz488n7aguCT5hIic5cTA36kP25pRClo_E6a-qHguPJ-DeaMgrhTGhHB-roJs-mgb_stEfsvKM1Fk86RyUGfNH5_eOnut9AbN9I7ApwkdeS-gJd_CRIp6opTq6HA7jy73F6_XXFaKwqO8VvzfKkOWHD4uKbffSltGEykM7MyjlD-q8gV0xc0tE-eZ4628X7-mnqXyIJgZ2AUq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