<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From ea538d3975c94c5d0a3d2eb2b0ab9f98fa182089 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov &lt;vital.had@gmail.com&gt;
Date: Thu, 25 Jul 2024 11:10:58 +0800
Subject: [PATCH] Revert breaking commit re threadlocal

---
 folly/ThreadLocal.h                   | 8 ++++----
 folly/concurrency/memory/TLRefCount.h | 2 +-
 folly/settings/detail/SettingsImpl.h  | 2 +-
 folly/test/ThreadLocalTest.cpp        | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git folly/ThreadLocal.h folly/ThreadLocal.h
index 114b30f20..a610d3d4f 100644
--- folly/ThreadLocal.h
+++ folly/ThreadLocal.h
@@ -67,9 +67,9 @@ class ThreadLocalPtr;
 template &lt;class T, class Tag = void, class AccessMode = void&gt;
 class ThreadLocal {
  public:
-  constexpr ThreadLocal() : constructor_([]() { return T(); }) {}
+  constexpr ThreadLocal() : constructor_([]() { return new T(); }) {}
 
-  template &lt;typename F, std::enable_if_t&lt;is_invocable_r_v&lt;T, F&gt;, int&gt; = 0&gt;
+  template &lt;typename F, std::enable_if_t&lt;is_invocable_r_v&lt;T*, F&gt;, int&gt; = 0&gt;
   explicit ThreadLocal(F&amp;&amp; constructor)
       : constructor_(std::forward&lt;F&gt;(constructor)) {}
 
@@ -100,13 +100,13 @@ class ThreadLocal {
   ThreadLocal&amp; operator=(const ThreadLocal&amp;) = delete;
 
   FOLLY_NOINLINE T* makeTlp() const {
-    auto const ptr = new T(constructor_());
+    auto const ptr = static_cast&lt;T*&gt;(constructor_());
     tlp_.reset(ptr);
     return ptr;
   }
 
   mutable ThreadLocalPtr&lt;T, Tag, AccessMode&gt; tlp_;
-  std::function&lt;T()&gt; constructor_;
+  std::function&lt;void*()&gt; constructor_;
 };
 
 /*
diff --git folly/concurrency/memory/TLRefCount.h folly/concurrency/memory/TLRefCount.h
index 88ecb2666..f0c24c72a 100644
--- folly/concurrency/memory/TLRefCount.h
+++ folly/concurrency/memory/TLRefCount.h
@@ -27,7 +27,7 @@ class TLRefCount {
   using Int = int64_t;
 
   TLRefCount()
-      : localCount_([&amp;]() { return LocalRefCount(*this); }),
+      : localCount_([&amp;]() { return new LocalRefCount(*this); }),
         collectGuard_(this, [](void*) {}) {}
 
   ~TLRefCount() noexcept {
diff --git folly/settings/detail/SettingsImpl.h folly/settings/detail/SettingsImpl.h
index 42ddb3048..740dfe963 100644
--- folly/settings/detail/SettingsImpl.h
+++ folly/settings/detail/SettingsImpl.h
@@ -387,7 +387,7 @@ class SettingCore : public SettingCoreBase {
         defaultValue_(std::move(defaultValue)),
         trivialStorage_(trivialStorage),
         localValue_([]() {
-          return cacheline_aligned&lt;
+          return new cacheline_aligned&lt;
               std::pair&lt;Version, std::shared_ptr&lt;Contents&gt;&gt;&gt;(
               std::in_place, 0, nullptr);
         }) {
diff --git folly/test/ThreadLocalTest.cpp folly/test/ThreadLocalTest.cpp
index f9482538d..4fa1acd1f 100644
--- folly/test/ThreadLocalTest.cpp
+++ folly/test/ThreadLocalTest.cpp
@@ -261,7 +261,7 @@ TEST(ThreadLocal, NotDefaultConstructible) {
     explicit Object(int v) : value{v} {}
   };
   std::atomic&lt;int&gt; a{};
-  ThreadLocal&lt;Object&gt; o{[&amp;a] { return Object(a++); }};
+  ThreadLocal&lt;Object&gt; o{[&amp;a] { return new Object(a++); }};
   EXPECT_EQ(0, o-&gt;value);
   std::thread([&amp;] { EXPECT_EQ(1, o-&gt;value); }).join();
 }
</pre></body></html>