diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c974642ff9..b729413c20b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1156,6 +1156,7 @@ if (BUILD_TESTS OR BUILD_BENCHMARKS) TEST unit_test SOURCES UnitTest.cpp BENCHMARK uri_benchmark SOURCES UriBenchmark.cpp TEST uri_test SOURCES UriTest.cpp + TEST utility_test SOURCES UtilityTest.cpp TEST varint_test SOURCES VarintTest.cpp DIRECTORY testing/test/ diff --git a/folly/Utility.h b/folly/Utility.h index 2e9d6a6b9f8..8b40205c8af 100644 --- a/folly/Utility.h +++ b/folly/Utility.h @@ -274,7 +274,7 @@ inline constexpr identity_fn identity{}; /// } template struct literal_string { - C buffer[N]; + C buffer[N] = {}; FOLLY_CONSTEVAL /* implicit */ literal_string(C const (&buf)[N]) noexcept { for (std::size_t i = 0; i < N; ++i) { diff --git a/folly/test/UtilityTest.cpp b/folly/test/UtilityTest.cpp index 32867ceade2..430e5776f9b 100644 --- a/folly/test/UtilityTest.cpp +++ b/folly/test/UtilityTest.cpp @@ -191,6 +191,8 @@ TEST_F(UtilityTest, forward_like) { // folly::forward_like(1); } +static_assert(!std::is_default_constructible_v>); + TEST_F(UtilityTest, literal_string) { constexpr auto s = folly::literal_string{"hello world"}; EXPECT_STREQ("hello world", s.c_str());