[PATCH] D83263: [WIP] Clang crashed while checking for deletion of copy and move ctors

Vy Nguyen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 6 15:19:08 PDT 2020


oontvoo created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repro:

- Annotate the unique_ptr class with trivial_abi (eg., https://godbolt.org/z/-rprsc)
- ./build/bin/clang++ -stdlib=libc++ -I../libcxx/memory

Crash:

  @     0x559d129463fc  clang::CXXRecordDecl::defaultedCopyConstructorIsDeleted()
   @     0x559d1288d3e5  clang::Sema::checkIllFormedTrivialABIStruct()::$_7::operator()()
   @     0x559d12884c34  clang::Sema::checkIllFormedTrivialABIStruct()
   @     0x559d1288412e  clang::Sema::CheckCompletedCXXClass()
   @     0x559d1288d843  clang::Sema::ActOnFinishCXXMemberSpecification()
   @     0x559d12020109  clang::Parser::ParseCXXMemberSpecification()
   @     0x559d1201e80c  clang::Parser::ParseClassSpecifier()
   @     0x559d1204e807  clang::Parser::ParseDeclarationSpecifiers()
   @     0x559d120e9aa9  clang::Parser::ParseSingleDeclarationAfterTemplate()
   @     0x559d120e8f21  clang::Parser::ParseTemplateDeclarationOrSpecialization()
   @     0x559d120e8886  clang::Parser::ParseDeclarationStartingWithTemplate()
   @     0x559d1204a1d4  clang::Parser::ParseDeclaration()
   @     0x559d12004b1d  clang::Parser::ParseExternalDeclaration()
   @     0x559d12017689  clang::Parser::ParseInnerNamespace()
   @     0x559d12017024  clang::Parser::ParseNamespace()
   @     0x559d1204a29b  clang::Parser::ParseDeclaration()
   @     0x559d12004c74  clang::Parser::ParseExternalDeclaration()


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83263

Files:
  clang/lib/Sema/SemaDeclCXX.cpp


Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -9719,6 +9719,11 @@
 
   // Ill-formed if the copy and move constructors are deleted.
   auto HasNonDeletedCopyOrMoveConstructor = [&]() {
+    // If we know there exist users-defined move/copy ctors, don't try to infer
+    // the deletion of implicit ones becausee Sema may not have the info yet.
+    if (RD.hasUserDeclaredMoveConstructor() ||
+        RD.hasUserDeclaredCopyConstructor())
+      return true;
     if (RD.needsImplicitCopyConstructor() &&
         !RD.defaultedCopyConstructorIsDeleted())
       return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83263.275849.patch
Type: text/x-patch
Size: 708 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200706/ee393aee/attachment.bin>


More information about the cfe-commits mailing list