From a6e257a52099066cd8baf2f942412aa51fcede10 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 4 Apr 2014 13:14:20 -0700 Subject: [PATCH] folly: allow to build with clang.dev (flex arrays vs. lambda) Summary: * folly/test/CacheLocalityTest.cpp (contentionAtWidth): Work around clang's prohibition against using flexible arrays in a lambda. Test Plan: fbconfig --clang --with-project-version clang:dev folly/test \ && fbmake runtests Reviewed By: ngbronson@fb.com FB internal diff: D1263620 --- folly/test/CacheLocalityTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/folly/test/CacheLocalityTest.cpp b/folly/test/CacheLocalityTest.cpp index 1d870a0a..3a739a00 100644 --- a/folly/test/CacheLocalityTest.cpp +++ b/folly/test/CacheLocalityTest.cpp @@ -528,7 +528,7 @@ static void contentionAtWidth(size_t iters, size_t stripes, size_t work, // that we get contention on 128 byte boundaries for Ivy Bridge. The // extra indirection adds 1 or 2 nanos assert(counterAlignment >= sizeof(std::atomic)); - char raw[counterAlignment * stripes]; + std::vector raw(counterAlignment * stripes); // if we happen to be using the tlsRoundRobin, then sequentially // assigning the thread identifiers is the unlikely best-case scenario. @@ -543,7 +543,8 @@ static void contentionAtWidth(size_t iters, size_t stripes, size_t work, threads.push_back(std::thread([&,iters,stripes,work]() { std::atomic* counters[stripes]; for (size_t i = 0; i < stripes; ++i) { - counters[i] = new (raw + counterAlignment * i) std::atomic(); + counters[i] + = new (raw.data() + counterAlignment * i) std::atomic(); } spreader.current(); @@ -702,4 +703,3 @@ int main(int argc, char** argv) { } return ret; } - -- 2.34.1