From c6c79a093200f51844b360d7aaa1187cd2a6ca30 Mon Sep 17 00:00:00 2001 From: Federico Busato Date: Tue, 5 Jul 2022 16:21:17 -0700 Subject: [PATCH] pointless comparison of unsigned integer with zero --- include/fmt/chrono.h | 3 ++- include/fmt/core.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index c3c52bf5..f99461fa 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -1396,7 +1396,8 @@ inline bool isfinite(T) { // Converts value to Int and checks that it's in the range [0, upper). template ::value)> inline Int to_nonnegative_int(T value, Int upper) { - FMT_ASSERT(value >= 0 && to_unsigned(value) <= to_unsigned(upper), + FMT_ASSERT(std::is_unsigned::value || + (value >= 0 && to_unsigned(value) <= to_unsigned(upper)), "invalid value"); (void)upper; return static_cast(value); diff --git a/include/fmt/core.h b/include/fmt/core.h index 0e7843b8..4bfb742f 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -402,7 +402,7 @@ template auto convert_for_visit(T) -> monostate { return {}; } template FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned::type { - FMT_ASSERT(value >= 0, "negative value"); + FMT_ASSERT(std::is_unsigned::value || value >= 0, "negative value"); return static_cast::type>(value); }