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 823f2ebf68aa3a2781de014404e3f8762d590388..07564a43fc46a6406d75adeaf09f102e0903c26e 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 89ddc023bea2a75361c0a6d2b62d7eff60bb1cbb..1541201caf71a79bcb615d2d16611b4d3bec140e 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));
   }
 }