Fix Build: folly with -Wmissing-braces
authorYedidya Feldblum <yfeldblum@fb.com>
Fri, 18 Nov 2016 07:01:42 +0000 (23:01 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Fri, 18 Nov 2016 07:09:06 +0000 (23:09 -0800)
Summary:
[Folly] Fix Build: `folly` with `-Wmissing-braces`.

Construction of `std::array` with list-initialization for the contained C array requires double braces, per the standard.

Compilers accept it with single braces, but will reject it when `-Wmissing-braces` is passed.

Reviewed By: igorsugak, meyering

Differential Revision: D4202629

fbshipit-source-id: e5b87a655e7f25e6cddb931dda28b172c768f227

folly/Array.h
folly/futures/test/FutureTest.cpp
folly/test/RangeTest.cpp

index 77faafe34d75e8c12752e5136fec2870efcd4f0a..7ca3b6ca49f169fda66baf2787a09e52a70deb08 100644 (file)
@@ -53,7 +53,7 @@ template <typename D = void, typename... TList>
 constexpr array_detail::return_type<D, TList...> make_array(TList&&... t) {
   using value_type =
       typename array_detail::return_type_helper<D, TList...>::type;
-  return {static_cast<value_type>(std::forward<TList>(t))...};
+  return {{static_cast<value_type>(std::forward<TList>(t))...}};
 }
 
 } // !folly
index 8a66184af8e5dceec1417c8eac57244ab9104f31..7d0275d6013d9f86eb7d8fd68e917cfb9b9963a3 100644 (file)
@@ -620,7 +620,7 @@ TEST(Future, finishBigLambda) {
   // bulk_data, to be captured in the lambda passed to Future::then.
   // This is meant to force that the lambda can't be stored inside
   // the Future object.
-  std::array<char, sizeof(detail::Core<int>)> bulk_data = {0};
+  std::array<char, sizeof(detail::Core<int>)> bulk_data = {{0}};
 
   // suppress gcc warning about bulk_data not being used
   EXPECT_EQ(bulk_data[0], 0);
index 5861b60f4ed29d31a5db0759affab4bc532abe75..827e085cd9645d06a8b98f34f6a851d1dafc3bff 100644 (file)
@@ -1111,7 +1111,7 @@ TEST(RangeFunc, ConstexprCArray) {
 }
 
 TEST(RangeFunc, ConstexprStdArray) {
-  static constexpr const std::array<int, 4> numArray = {3, 17, 1, 9};
+  static constexpr const std::array<int, 4> numArray = {{3, 17, 1, 9}};
   constexpr const auto numArrayRange = range(numArray);
   EXPECT_EQ(17, numArrayRange[1]);
   constexpr const auto numArrayRangeSize = numArrayRange.size();