[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:16:12 PST 2025


https://github.com/2LoS created https://github.com/llvm/llvm-project/pull/125723

None

>From fb9032fa397b399affb27757e67f85d30b2ace65 Mon Sep 17 00:00:00 2001
From: LoS <aurumpuro at gmail.com>
Date: Tue, 4 Feb 2025 18:21:30 +0100
Subject: [PATCH] Fixed Reference copy and move assignment operators

---
 .../robust_against_proxy_iterators_lifetime_bugs.pass.cpp   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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 c89d6f5a229e8ad..e39881a5e5a3ba1 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;
     }
 



More information about the libcxx-commits mailing list