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;
This commit is contained in:
Björn Schäpers 2022-09-11 11:16:07 +02:00 committed by Victor Zverovich
parent 192859c2b5
commit 042af53324

View File

@ -2585,14 +2585,14 @@ template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value&&
FMT_CONSTEXPR20 bool isfinite(T value) {
constexpr T inf = T(std::numeric_limits<double>::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 <typename T, FMT_ENABLE_IF(!has_isfinite<T>::value)>
FMT_CONSTEXPR bool isfinite(T value) {
T inf = T(std::numeric_limits<double>::infinity());
// std::isfinite doesn't support __float128.
return !detail::isnan(value) && value != inf && value != -inf;
return !detail::isnan(value) && value < inf && value > -inf;
}
template <typename T, FMT_ENABLE_IF(is_floating_point<T>::value)>