diff --git a/au/math_test.cc b/au/math_test.cc index e0709556..5b71b2a1 100644 --- a/au/math_test.cc +++ b/au/math_test.cc @@ -227,7 +227,7 @@ struct ExpectConsistentWith { }; template auto expect_consistent_with(AuFunc au_func, StdFunc std_func) { - return ExpectConsistentWith{.au_func = au_func, .std_func = std_func}; + return ExpectConsistentWith{au_func, std_func}; } TEST(fmod, SameAsStdFmodForNumericTypes) { diff --git a/au/quantity_chrono_policy_correspondence_test.cc b/au/quantity_chrono_policy_correspondence_test.cc index 121cd8d7..a426fc26 100644 --- a/au/quantity_chrono_policy_correspondence_test.cc +++ b/au/quantity_chrono_policy_correspondence_test.cc @@ -44,14 +44,14 @@ bool operator==(const AllComparisons &a, const AllComparisons &b) { template AllComparisons compare(const T &t, const U &u) { - return { - .eq = (t == u), - .ne = (t != u), - .lt = (t < u), - .le = (t <= u), - .gt = (t > u), - .ge = (t >= u), - }; + AllComparisons result; + result.eq = (t == u); + result.ne = (t != u); + result.lt = (t < u); + result.le = (t <= u); + result.gt = (t > u); + result.ge = (t >= u); + return result; } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/au/quantity_test.cc b/au/quantity_test.cc index ccf2bf74..feebdf94 100644 --- a/au/quantity_test.cc +++ b/au/quantity_test.cc @@ -286,21 +286,21 @@ struct CorrespondingQuantity { static constexpr Rep extract_value(MyHours x) { return x.value; } // Support Quantity conversion to Hours. - static constexpr MyHours construct_from_value(Rep x) { return {.value = x}; } + static constexpr MyHours construct_from_value(Rep x) { return {x}; } }; TEST(Quantity, ImplicitConstructionFromCorrespondingQuantity) { - constexpr Quantity x = MyHours{.value = 3}; + constexpr Quantity x = MyHours{3}; EXPECT_EQ(x, hours(3)); } TEST(Quantity, ImplicitConstructionFromTwoHopCorrespondingQuantity) { - constexpr Quantity x = MyHours{.value = 3}; + constexpr Quantity x = MyHours{3}; EXPECT_THAT(x, SameTypeAndValue(minutes(180))); } TEST(Quantity, ImplicitConstructionFromLvalueCorrespondingQuantity) { - MyHours original{.value = 10}; + MyHours original{10}; const Quantity converted = original; EXPECT_EQ(converted, hours(10)); } @@ -322,7 +322,7 @@ TEST(Quantity, ImplicitConversionToLvalueCorrespondingQuantity) { } TEST(AsQuantity, DeducesCorrespondingQuantity) { - constexpr auto q = as_quantity(MyHours{.value = 8}); + constexpr auto q = as_quantity(MyHours{8}); EXPECT_THAT(q, QuantityEquivalent(hours(8))); } diff --git a/au/utility/string_constant.hh b/au/utility/string_constant.hh index acec672d..8964f9b9 100644 --- a/au/utility/string_constant.hh +++ b/au/utility/string_constant.hh @@ -105,9 +105,9 @@ constexpr std::size_t string_size(int64_t x) { template constexpr std::size_t sum() { std::size_t result{0}; - std::size_t values[] = {Ns...}; + std::size_t values[] = {0u, Ns...}; // Dummy `0u` avoids empty array. for (std::size_t i = 0; i < sizeof...(Ns); ++i) { - result += values[i]; + result += values[i + 1u]; // "+ 1u" to skip the dummy value. } return result; } diff --git a/build/copts.bzl b/build/copts.bzl index f1147cf1..3df30e51 100644 --- a/build/copts.bzl +++ b/build/copts.bzl @@ -16,6 +16,7 @@ # -Wall is already set by aspect_gcc_toolchain. EXTRA_COPTS = [ "-Wextra", + "-pedantic", ] # Since the clang toolchain we're using doesn't let us extract the default flags, we have to