diff --git a/format.cc b/format.cc index f488bcf7..6a78b941 100644 --- a/format.cc +++ b/format.cc @@ -253,8 +253,8 @@ class ArgConverter : public fmt::internal::ArgVisitor, void> { arg_.int_value = static_cast(static_cast(value)); } else { arg_.type = Arg::UINT; - arg_.uint_value = - static_cast::Type>(value); + arg_.uint_value = static_cast( + static_cast::Type>(value)); } } else { if (is_signed) { diff --git a/test/printf-test.cc b/test/printf-test.cc index dfb022b7..df938ced 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -296,7 +296,8 @@ void TestLength(const char *length_spec, U value) { if (max <= std::numeric_limits::max()) { signed_value = static_cast(value); unsigned_value = static_cast(value); - } else if (max <= std::numeric_limits::max()) { + } else if (static_cast(max) <= + std::numeric_limits::max()) { signed_value = static_cast(value); unsigned_value = static_cast(value); } @@ -333,8 +334,10 @@ void TestLength(const char *length_spec) { TestLength(length_spec, -42); TestLength(length_spec, min); TestLength(length_spec, max); - if (min > std::numeric_limits::min()) + if (min >= 0 || static_cast(min) > + std::numeric_limits::min()) { TestLength(length_spec, fmt::LongLong(min) - 1); + } if (max < std::numeric_limits::max()) TestLength(length_spec, fmt::LongLong(max) + 1); TestLength(length_spec, std::numeric_limits::min());