gcc-4.8 is not decaying types correctly in lambda init captures. Help it out. Fixes...
authorEric Niebler <eniebler@fb.com>
Wed, 29 Jun 2016 22:43:31 +0000 (15:43 -0700)
committerFacebook Github Bot 3 <facebook-github-bot-3-bot@fb.com>
Wed, 29 Jun 2016 22:53:36 +0000 (15:53 -0700)
Summary: Trivial change gets folly::ThreadLocal building again with gcc-4.8, needed by the Open Source build.

Reviewed By: chadparry, yfeldblum

Differential Revision: D3498657

fbshipit-source-id: cf36f2bef7f1d03d133d16bfd063f7a2ce681822

folly/detail/ThreadLocalDetail.h

index ea9ae136b617a4f74899bf19514af3df36805978..3bcfbfa24b6a451e56ac1c318c0c26119e017482 100644 (file)
@@ -107,10 +107,11 @@ struct ElementWrapper {
     DCHECK(deleter2 == nullptr);
     if (p) {
       ptr = p;
-      deleter2 = new std::function<DeleterFunType>([d = d](
-          void* pt, TLPDestructionMode mode) {
-        d(static_cast<Ptr>(pt), mode);
-      });
+      auto d2 = d; // gcc-4.8 doesn't decay types correctly in lambda captures
+      deleter2 = new std::function<DeleterFunType>(
+          [d2](void* pt, TLPDestructionMode mode) {
+            d2(static_cast<Ptr>(pt), mode);
+          });
       ownsDeleter = true;
       guard.dismiss();
     }