[gcc(refs/users/ppalka/heads/libstdcxx-constrained-algos)] Make use-after-move errors easily detectable in the testsuite iterators

Patrick Palka ppalka@gcc.gnu.org
Mon Jan 27 15:26:00 GMT 2020


https://gcc.gnu.org/g:597cb3a100338d6f7ae04db3170654a88e0b225d

commit 597cb3a100338d6f7ae04db3170654a88e0b225d
Author: Patrick Palka <ppalka@redhat.com>
Date:   Sun Jan 26 23:01:13 2020 -0500

    Make use-after-move errors easily detectable in the testsuite iterators

Diff:
---
 libstdc++-v3/testsuite/util/testsuite_iterators.h | 28 +++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h
index a1071a6..b673634 100644
--- a/libstdc++-v3/testsuite/util/testsuite_iterators.h
+++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h
@@ -142,6 +142,20 @@ namespace __gnu_test
 
     output_iterator_wrapper&
     operator=(const output_iterator_wrapper&) = default;
+
+    output_iterator_wrapper(output_iterator_wrapper&& other)
+    {
+      *this = std::move(other);
+    }
+
+    output_iterator_wrapper&
+    operator=(output_iterator_wrapper&& other)
+    {
+      *this = other;
+      if (this != &other)
+	other.ptr = nullptr;
+      return *this;
+    }
 #endif
 
     WritableObject<T>
@@ -224,6 +238,20 @@ namespace __gnu_test
 
     input_iterator_wrapper&
     operator=(const input_iterator_wrapper&) = default;
+
+    input_iterator_wrapper(input_iterator_wrapper&& other)
+    {
+      *this = std::move(other);
+    }
+
+    input_iterator_wrapper&
+    operator=(input_iterator_wrapper&& other)
+    {
+      *this = other;
+      if (this != &other)
+	other.ptr = nullptr;
+      return *this;
+    }
 #endif
 
     bool



More information about the Libstdc++-cvs mailing list