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

    <tr>
        <th>Summary</th>
        <td>
            Clang crashes on invalid code in C++20 mode
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          ilya-biryukov
      </td>
    </tr>
</table>

<pre>
    Input:
```
class a
struct b {
  c;
  a e;
  d() {
    b( {
    }
 }
}
```
Crashes when compiled with `clang++ -std=c++20` and produces the following stack trace (when assertions are enabled):
```
clang++: /root/llvm-project/clang/lib/Sema/SemaLookup.cpp:3346: clang::Sema::SpecialMemberOverloadResult clang::Sema::LookupSpecialMember(clang::CXXRecordDecl*, clang::Sema::CXXSpecialMember, bool, bool, bool, bool, bool): Assertion `CanDeclareSpecialMemberFunction(RD) && "doing special member lookup into record that isn't fully complete"' failed.
...
1.      <source>:8:3: current parser token '}'
2.      <source>:2:1: parsing struct/union/class body 'b'
3.      <source>:5:7: parsing function body 'b::d'
4.      <source>:5:7: in compound statement ('{}')
...
 #9 0x0000000006780474 clang::Sema::LookupSpecialMember(clang::CXXRecordDecl*, clang::Sema::CXXSpecialMember, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6780474)
#10 0x00000000067808a7 clang::Sema::LookupDefaultConstructor(clang::CXXRecordDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67808a7)
#11 0x0000000006721068 TryValueInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, clang::InitializationSequence&, clang::InitListExpr*) SemaInit.cpp:0:0
#12 0x0000000006727ee7 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+++0x6727ee7)
#13 0x0000000006726960 TryOrBuildParenListInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::ArrayRef<clang::Expr*>, clang::InitializationSequence&, bool, clang::ActionResult<clang::Expr*, true>*)::'lambda'(clang::InitializedEntity const&, clang::InitializationKind const&, clang::Expr*, clang::Expr**)::operator()(clang::InitializedEntity const&, clang::InitializationKind const&, clang::Expr*, clang::Expr**) const SemaInit.cpp:0:0
#14 0x0000000006727747 TryOrBuildParenListInitialization(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::ArrayRef<clang::Expr*>, clang::InitializationSequence&, bool, clang::ActionResult<clang::Expr*, true>*) SemaInit.cpp:0:0
#15 0x0000000006729380 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+++0x6729380)
#16 0x0000000006642a01 clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6642a01)
#17 0x00000000066cd1cd clang::Sema::ActOnCXXTypeConstructExpr(clang::OpaquePtr<clang::QualType>, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66cd1cd)
...
```

See https://gcc.godbolt.org/z/jadhdMxjf

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWFFv2yoU_jXkBTUikNrOQx7ctJamu6m77XTVVwwnDSsBD3DX7NdfAUkaZ1FbTdrurrQqTQw-fD7n43zHAPde3RuAOTq_QOeXI96HlXVzpTf8rFVu0z_Yx1Fr5Wb-znR9QKxG5BKRGhVk-0lNobn3mOeGD64XAbcYlRe5B2OB2P6aYzhoSUQrRGeHx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