PackedSyncPtr.data_ is private
authorChristopher Dykes <cdykes@fb.com>
Wed, 1 Jun 2016 22:34:02 +0000 (15:34 -0700)
committerFacebook Github Bot 6 <facebook-github-bot-6-bot@fb.com>
Wed, 1 Jun 2016 22:38:31 +0000 (15:38 -0700)
Summary: As the (now removed) comment says, GCC 4.6 doesn't treat structs with private members as POD types... The thing is, GCC 4.6 is long dead, so make `data_` private and assert that it's a POD type.

Reviewed By: meyering

Differential Revision: D3373172

fbshipit-source-id: b2f1ee59d544461fe986705164cc6c866af62865

folly/PackedSyncPtr.h

index 74c5ab8f63daf26349a88303b8828f34ed9f9436..00dc1e22419d38e975b37677bc2667547c218294 100644 (file)
@@ -133,14 +133,13 @@ public:
     data_.setData((uintptr_t(extra) << 48) | ptr);
   }
 
-  // Logically private, but we can't have private data members and
-  // still be considered a POD.  (In C++11 we are still a standard
-  // layout struct if this is private, but it doesn't matter, since
-  // gcc (4.6) won't let us use this with attribute packed still in
-  // that case.)
+ private:
   PicoSpinLock<uintptr_t> data_;
 };
 
+static_assert(
+    std::is_pod<PackedSyncPtr<void>>::value,
+    "PackedSyncPtr must be kept a POD type.");
 static_assert(sizeof(PackedSyncPtr<void>) == 8,
               "PackedSyncPtr should be only 8 bytes---something is "
               "messed up");