From: Yedidya Feldblum Date: Sat, 9 Dec 2017 17:47:06 +0000 (-0800) Subject: Fix UBSAN failure in RangeTest.cpp with libstdc++-v4.9 X-Git-Tag: v2017.12.11.00~5 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=2d3c33462242cada87a857143101cd99cd94b8f8;p=folly.git Fix UBSAN failure in RangeTest.cpp with libstdc++-v4.9 Summary: [Folly] Fix UBSAN failure in `RangeTest.cpp` with `libstdc++-v4.9`. The implementation of `std::array` in `libstdc++-v4.9` has undefined behavior in the case of the zero-length array - dereferencing (but immediately taking the address again) of `nullptr`. This is fixed in `libstdc++-v5`. Reviewed By: ot Differential Revision: D6528614 fbshipit-source-id: 26be6bdc28d9e6dc6e6293a4d4ecffd769c01413 --- diff --git a/folly/test/RangeTest.cpp b/folly/test/RangeTest.cpp index dbe8d88f..b1298cac 100644 --- a/folly/test/RangeTest.cpp +++ b/folly/test/RangeTest.cpp @@ -1201,7 +1201,7 @@ TEST(CRangeFunc, StdArrayZero) { auto const numArrayRange = crange(numArray); EXPECT_TRUE( (std::is_same::value)); - EXPECT_THAT(numArrayRange, testing::ElementsAreArray(numArray)); + EXPECT_THAT(numArrayRange, testing::IsEmpty()); } TEST(CRangeFunc, Collection) {