Summary: In some cases, folly::threadlocal_detail::StaticMeta<void>::EntryID::kInvalid
is odr-used, a definition at the namespace scope is required even though it has
been initialized with a brace-or-equal initializer.
See http://en.cppreference.com/w/cpp/language/static
Reviewed By: @yfeldblum
Differential Revision:
D2548668
fb-gh-sync-id:
9cd6d7b2f37d1481d1adbf4f0a2d9e66631efd15
}
};
+template <class Tag>
+constexpr uint32_t StaticMeta<Tag>::EntryID::kInvalid;
+
#ifdef FOLLY_TLD_USE_FOLLY_TLS
template <class Tag>
FOLLY_TLS ThreadEntry StaticMeta<Tag>::threadEntry_ = {nullptr, 0,
#include <atomic>
#include <chrono>
#include <condition_variable>
+#include <limits.h>
#include <map>
#include <mutex>
#include <set>
EXPECT_EQ(wVersionMax * 10, Widget::totalVal_);
}
+TEST(ThreadLocalPtr, ODRUseEntryIDkInvalid) {
+ // EntryID::kInvalid is odr-used
+ // see http://en.cppreference.com/w/cpp/language/static
+ const uint32_t* pInvalid =
+ &(threadlocal_detail::StaticMeta<void>::EntryID::kInvalid);
+ EXPECT_EQ(std::numeric_limits<uint32_t>::max(), *pInvalid);
+}
+
class SimpleThreadCachedInt {
class NewTag;