Fix test Dynamic.ArrayReassignment with Clang 3.7
authorGiuseppe Ottaviano <ott@fb.com>
Wed, 23 Dec 2015 20:07:16 +0000 (12:07 -0800)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Wed, 23 Dec 2015 20:20:28 +0000 (12:20 -0800)
Summary:
`dynamic` is one of the few unfortunate recursive types that have a constructor of the form `T(initializer_list<T>)`. After the Defect Report 95 (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1467) a statement `T t = {v};` where `v` is of type `T` invokes the copy constructor instead of the initializer list constructor. Clang 3.7 implements the new behavior, and GCC probably will soon.
This diff only fixes a test where the ambiguous syntax is used, but a better solution would be preferable.

Reviewed By: philippv

Differential Revision: D2786455

fb-gh-sync-id: 7fa5235e4041cbc8dd3ce685b5a0c23c343f78d2

folly/test/DynamicTest.cpp

index 83e21cf6a4f810961f2598026359e46640d0aa05..a065e14bd9e5b01ce2fcb4fc42d312106e3a4b4d 100644 (file)
@@ -232,7 +232,9 @@ TEST(Dynamic, DeepCopy) {
 TEST(Dynamic, ArrayReassignment) {
   dynamic o = 1;
 
-  dynamic d1 = {o};
+  // After DR95 the single braces dispatch to the copy constructor.
+  // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1467
+  dynamic d1 = {{o}};
   EXPECT_EQ(dynamic::ARRAY, d1.type());
 
   d1 = {o};