Issue 76228
Summary Clang crashes on invalid code in C++20 mode
Labels
Assignees
Reporter ilya-biryukov
    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

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to