From 042af53324b3250ea38e9b98c79dcce5709ac726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Sun, 11 Sep 2022 11:16:07 +0200 Subject: [PATCH] Suppress -Wfloat-equal Only NaN and Inf are not less than Inf and the check for NaN is done before. Solves: .../fmt/include/fmt/format.h:2509:43: warning: comparing floating-point with '==' or '!=' is unsafe [-Wfloat-equal] 2509 | return !detail::isnan(value) && value != inf && value != -inf; --- include/fmt/format.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 124f022b..37f46686 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2585,14 +2585,14 @@ template ::value&& FMT_CONSTEXPR20 bool isfinite(T value) { constexpr T inf = T(std::numeric_limits::infinity()); if (is_constant_evaluated()) - return !detail::isnan(value) && value != inf && value != -inf; + return !detail::isnan(value) && value < inf && value > -inf; return std::isfinite(value); } template ::value)> FMT_CONSTEXPR bool isfinite(T value) { T inf = T(std::numeric_limits::infinity()); // std::isfinite doesn't support __float128. - return !detail::isnan(value) && value != inf && value != -inf; + return !detail::isnan(value) && value < inf && value > -inf; } template ::value)>