[libcxx-commits] [libcxx] Fixed Reference copy and move assignment operators (PR #125723)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 4 09:18:59 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: LoS (2LoS)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/125723.diff


1 Files Affected:

- (modified) libcxx/test/std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp (+3-3) 


``````````diff
diff --git a/libcxx/test/std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp b/libcxx/test/std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp
index c89d6f5a229e8a..e39881a5e5a3ba 100644
--- a/libcxx/test/std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp
+++ b/libcxx/test/std/algorithms/robust_against_proxy_iterators_lifetime_bugs.pass.cpp
@@ -159,7 +159,7 @@ class LifetimeIterator {
       assert(!rhs.moved_from_);
       rhs.moved_from_ = true;
 
-      *v_ = *rhs.v_;
+      *v_ = std::move(*rhs.v_);
       moved_from_ = false;
 
       return *this;
@@ -368,7 +368,7 @@ class ConstexprIterator {
     constexpr Reference(const Reference& rhs) = default;
     constexpr Reference& operator=(const Reference& rhs) {
       assert(!rhs.moved_from_);
-      v_ = rhs.v_;
+      *v_ = *rhs.v_;
       moved_from_ = false;
 
       return *this;
@@ -384,7 +384,7 @@ class ConstexprIterator {
       rhs.moved_from_ = true;
       moved_from_ = false;
 
-      v_ = rhs.v_;
+      *v_ = std::move(*rhs.v_);
       return *this;
     }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/125723


More information about the libcxx-commits mailing list