[libcxx-commits] [libcxx] e7c621a - [libc++][nfc] Test std::unique_ptr self move assignment.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 9 11:43:18 PDT 2021


Author: Mark de Wever
Date: 2021-06-09T20:43:12+02:00
New Revision: e7c621a607889e3df1e8becdb96817dbcf3933a4

URL: https://github.com/llvm/llvm-project/commit/e7c621a607889e3df1e8becdb96817dbcf3933a4
DIFF: https://github.com/llvm/llvm-project/commit/e7c621a607889e3df1e8becdb96817dbcf3933a4.diff

LOG: [libc++][nfc] Test std::unique_ptr self move assignment.

The post-conditions for the self move assignment of `std::unique_ptr`
were changed. This requires no implementation changes. A test was added
to validate the new post-conditions.

Addresses
- LWG-3455: Incorrect Postconditions on `unique_ptr` move assignment

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D103764

Added: 
    

Modified: 
    libcxx/docs/Cxx2bStatus.rst
    libcxx/docs/Cxx2bStatusIssuesStatus.csv
    libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/Cxx2bStatus.rst b/libcxx/docs/Cxx2bStatus.rst
index 541d8bf466c9d..1ecf2e9fa4983 100644
--- a/libcxx/docs/Cxx2bStatus.rst
+++ b/libcxx/docs/Cxx2bStatus.rst
@@ -47,4 +47,4 @@ Library Working Group Issues Status
    :header-rows: 1
    :widths: auto
 
-Last Updated: 01-Mar-2021
+Last Updated: 6-June-2021

diff  --git a/libcxx/docs/Cxx2bStatusIssuesStatus.csv b/libcxx/docs/Cxx2bStatusIssuesStatus.csv
index 15356409a0356..535475d557d3e 100644
--- a/libcxx/docs/Cxx2bStatusIssuesStatus.csv
+++ b/libcxx/docs/Cxx2bStatusIssuesStatus.csv
@@ -36,7 +36,7 @@
 "`3448 <https://wg21.link/LWG3448>`__","``transform_view``'s sentinel<false> not comparable with ``iterator<true>``","November 2020","",""
 "`3449 <https://wg21.link/LWG3449>`__","take_view and take_while_view's ``sentinel<false>`` not comparable with their const iterator","November 2020","",""
 "`3453 <https://wg21.link/LWG3453>`__","Generic code cannot call ``ranges::advance(i, s)``","November 2020","",""
-"`3455 <https://wg21.link/LWG3455>`__","Incorrect Postconditions on ``unique_ptr`` move assignment","November 2020","",""
+"`3455 <https://wg21.link/LWG3455>`__","Incorrect Postconditions on ``unique_ptr`` move assignment","November 2020","|Nothing To Do|",""
 "`3460 <https://wg21.link/LWG3460>`__","Unimplementable ``noop_coroutine_handle`` guarantees","November 2020","",""
 "`3461 <https://wg21.link/LWG3461>`__","``convertible_to``'s description mishandles cv-qualified void","November 2020","",""
 "`3465 <https://wg21.link/LWG3465>`__","compare_partial_order_fallback requires ``F < E``","November 2020","",""

diff  --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp
index 87c260b45de19..4057534fe7df3 100644
--- a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp
+++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move.pass.cpp
@@ -8,6 +8,9 @@
 
 // UNSUPPORTED: c++03
 
+// Self assignement post-conditions are tested.
+// ADDITIONAL_COMPILE_FLAGS: -Wno-self-move
+
 // <memory>
 
 // unique_ptr
@@ -72,6 +75,14 @@ void test_basic() {
     assert(d2.state() == 5);
   }
   assert(A::count == 0);
+  {
+    std::unique_ptr<VT> s(newValue<VT>(expect_alive));
+    A* p = s.get();
+    s = std::move(s);
+    assert(A::count == expect_alive);
+    assert(s.get() == p);
+  }
+  assert(A::count == 0);
 }
 
 template <bool IsArray>


        


More information about the libcxx-commits mailing list