Commit 77a85008 authored by Jody Ho's avatar Jody Ho Committed by facebook-github-bot-9

undefined reference to 'folly::threadlocal_detail::StaticMeta<void>::EntryID::kInvalid'

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
parent f7176051
......@@ -524,6 +524,9 @@ struct StaticMeta {
}
};
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,
......
......@@ -24,6 +24,7 @@
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <limits.h>
#include <map>
#include <mutex>
#include <set>
......@@ -249,6 +250,14 @@ TEST(ThreadLocal, InterleavedDestructors) {
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment