fix hazptr_array move
authorDave Watson <davejwatson@fb.com>
Tue, 21 Nov 2017 15:33:09 +0000 (07:33 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 21 Nov 2017 15:37:24 +0000 (07:37 -0800)
Summary: Broken, found via build failures in D6259947

Reviewed By: yfeldblum

Differential Revision: D6374215

fbshipit-source-id: 3a438b5416683c602966c2f029c6b7787acdccaa

folly/experimental/hazptr/hazptr-impl.h
folly/experimental/hazptr/test/HazptrTest.cpp

index 823f2eb..07564a4 100644 (file)
@@ -452,9 +452,10 @@ FOLLY_ALWAYS_INLINE hazptr_array<M>::hazptr_array(
     hazptr_array&& other) noexcept {
   DEBUG_PRINT(this << " " << M << " " << &other);
   auto h = reinterpret_cast<hazptr_holder*>(&raw_);
+  auto hother = reinterpret_cast<hazptr_holder*>(&other.raw_);
   for (size_t i = 0; i < M; ++i) {
-    new (&h[i]) hazptr_holder(std::move(other.h_[i]));
-    DEBUG_PRINT(i << " " << &h[i] << " " << &other.h_[i]);
+    new (&h[i]) hazptr_holder(std::move(hother[i]));
+    DEBUG_PRINT(i << " " << &h[i] << " " << &hother[i]);
   }
   empty_ = other.empty_;
   other.empty_ = true;
index 89ddc02..1541201 100644 (file)
@@ -380,6 +380,7 @@ TEST_F(HazptrTest, Array) {
   {
     // Abnormal case
     hazptr_array<HAZPTR_TC_SIZE + 1> h;
+    hazptr_array<HAZPTR_TC_SIZE + 1> h2(std::move(h));
   }
 }