From: Christopher Dykes Date: Sat, 20 May 2017 03:33:41 +0000 (-0700) Subject: Mark constexpr values needed within non-implicitly-capturing lambdas as static X-Git-Tag: v2017.05.22.00~5 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=79e5fd2fa293cf03269d4b7bba9ed7a31dda1cd8;p=folly.git Mark constexpr values needed within non-implicitly-capturing lambdas as static 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 --- diff --git a/folly/fibers/test/FibersTest.cpp b/folly/fibers/test/FibersTest.cpp index c917eaa5..733ba7c2 100644 --- a/folly/fibers/test/FibersTest.cpp +++ b/folly/fibers/test/FibersTest.cpp @@ -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()); folly::EventBase evb; dynamic_cast(manager.loopController()) diff --git a/folly/futures/test/BarrierTest.cpp b/folly/futures/test/BarrierTest.cpp index b3419d14..3fa3cc05 100644 --- a/folly/futures/test/BarrierTest.cpp +++ b/folly/futures/test/BarrierTest.cpp @@ -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 { diff --git a/folly/io/test/CompressionTest.cpp b/folly/io/test/CompressionTest.cpp index 3036ba6d..e8b9312e 100644 --- a/folly/io/test/CompressionTest.cpp +++ b/folly/io/test/CompressionTest.cpp @@ -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(); diff --git a/folly/test/AtomicLinkedListTest.cpp b/folly/test/AtomicLinkedListTest.cpp index 97f4b160..80cf452e 100644 --- a/folly/test/AtomicLinkedListTest.cpp +++ b/folly/test/AtomicLinkedListTest.cpp @@ -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 elements; for (size_t i = 0; i < kNumThreads * kNumElements; ++i) { diff --git a/folly/test/SingletonThreadLocalTest.cpp b/folly/test/SingletonThreadLocalTest.cpp index 43011471..4703dde5 100644 --- a/folly/test/SingletonThreadLocalTest.cpp +++ b/folly/test/SingletonThreadLocalTest.cpp @@ -40,7 +40,7 @@ FooSingletonTL theFooSingleton; } TEST(SingletonThreadLocalTest, OneSingletonPerThread) { - const std::size_t targetThreadCount{64}; + static constexpr std::size_t targetThreadCount{64}; std::atomic completedThreadCount{0}; Synchronized> fooAddresses{}; std::vector threads{};