Mark constexpr values needed within non-implicitly-capturing lambdas as static
authorChristopher Dykes <cdykes@fb.com>
Sat, 20 May 2017 03:33:41 +0000 (20:33 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sat, 20 May 2017 03:40:28 +0000 (20:40 -0700)
Summary: MSVC needs these to be marked as `static` in order to be accessible within the lambdas without capturing them.

Reviewed By: yfeldblum

Differential Revision: D5099607

fbshipit-source-id: 0270e2191d504f74b1902789b662e1766b2056c4

folly/fibers/test/FibersTest.cpp
folly/futures/test/BarrierTest.cpp
folly/io/test/CompressionTest.cpp
folly/test/AtomicLinkedListTest.cpp
folly/test/SingletonThreadLocalTest.cpp

index c917eaa52a99b84148d22997e9594f8e35bfa65a..733ba7c2758ef1842f11ec78607efa7f0cddad6c 100644 (file)
@@ -1545,15 +1545,15 @@ TEST(FiberManager, nestedFiberManagers) {
 }
 
 TEST(FiberManager, semaphore) {
-  constexpr size_t kTasks = 10;
-  constexpr size_t kIterations = 10000;
-  constexpr size_t kNumTokens = 10;
+  static constexpr size_t kTasks = 10;
+  static constexpr size_t kIterations = 10000;
+  static constexpr size_t kNumTokens = 10;
 
   Semaphore sem(kNumTokens);
   int counterA = 0;
   int counterB = 0;
 
-  auto task = [&sem, kNumTokens](int& counter, folly::fibers::Baton& baton) {
+  auto task = [&sem](int& counter, folly::fibers::Baton& baton) {
     FiberManager manager(std::make_unique<EventBaseLoopController>());
     folly::EventBase evb;
     dynamic_cast<EventBaseLoopController&>(manager.loopController())
index b3419d14e1e17b80a526d5608eb0e582e704c460..3fa3cc05ee33fc89cb26685c6316c41b24be76e0 100644 (file)
@@ -112,7 +112,7 @@ TEST(BarrierTest, Random) {
   //
   // At the end, we verify that exactly one future returning true was seen
   // for each iteration.
-  constexpr uint32_t numIterations = 1;
+  static constexpr uint32_t numIterations = 1;
   auto numThreads = folly::Random::rand32(30, 91);
 
   struct ThreadInfo {
index 3036ba6d7328a1f9f062dcf17d713160d294141a..e8b9312eac76f26c330ad3c4ac4e316003f18294 100644 (file)
@@ -83,8 +83,8 @@ class RandomDataHolder : public DataHolder {
 
 RandomDataHolder::RandomDataHolder(size_t sizeLog2)
   : DataHolder(sizeLog2) {
-  constexpr size_t numThreadsLog2 = 3;
-  constexpr size_t numThreads = size_t(1) << numThreadsLog2;
+  static constexpr size_t numThreadsLog2 = 3;
+  static constexpr size_t numThreads = size_t(1) << numThreadsLog2;
 
   uint32_t seed = randomNumberSeed();
 
index 97f4b1609a4988f575c7644f51d1f741c5fde26f..80cf452eba855f674f338fc6a05aa03a729be6ca 100644 (file)
@@ -121,8 +121,8 @@ TEST(AtomicIntrusiveLinkedList, Move) {
 }
 
 TEST(AtomicIntrusiveLinkedList, Stress) {
-  constexpr size_t kNumThreads = 32;
-  constexpr size_t kNumElements = 100000;
+  static constexpr size_t kNumThreads = 32;
+  static constexpr size_t kNumElements = 100000;
 
   std::vector<TestIntrusiveObject> elements;
   for (size_t i = 0; i < kNumThreads * kNumElements; ++i) {
index 4301147177e7d343b098e0963df855ebd69ec1f4..4703dde525bed100eea5a8fd21862d3132a03bc3 100644 (file)
@@ -40,7 +40,7 @@ FooSingletonTL theFooSingleton;
 }
 
 TEST(SingletonThreadLocalTest, OneSingletonPerThread) {
-  const std::size_t targetThreadCount{64};
+  static constexpr std::size_t targetThreadCount{64};
   std::atomic<std::size_t> completedThreadCount{0};
   Synchronized<std::unordered_set<Foo*>> fooAddresses{};
   std::vector<std::thread> threads{};