diff --git a/format.h b/format.h index 30ad3658..2f645f76 100644 --- a/format.h +++ b/format.h @@ -232,6 +232,11 @@ inline DummyInt isinf(...) { return DummyInt(); } inline DummyInt _finite(...) { return DummyInt(); } inline DummyInt isnan(...) { return DummyInt(); } inline DummyInt _isnan(...) { return DummyInt(); } + +// A helper function to suppress bogus "conditional expression is constant" +// warnings. +template +inline T check(T value) { return value; } } } // namespace fmt @@ -250,24 +255,28 @@ class numeric_limits : using namespace fmt::internal; // The resolution "priority" is: // isinf macro > std::isinf > ::isinf > fmt::internal::isinf - if (sizeof(isinf(x)) == sizeof(bool) || sizeof(isinf(x)) == sizeof(int)) + if (check(sizeof(isinf(x)) == sizeof(bool) || + sizeof(isinf(x)) == sizeof(int))) { return isinf(x); - return !_finite(x); + } + return !_finite(static_cast(x)); } // Portable version of isnan. template static bool isnotanumber(T x) { using namespace fmt::internal; - if (sizeof(isnan(x)) == sizeof(bool) || sizeof(isnan(x)) == sizeof(int)) + if (check(sizeof(isnan(x)) == sizeof(bool) || + sizeof(isnan(x)) == sizeof(int))) { return isnan(x); - return _isnan(x) != 0; + } + return _isnan(static_cast(x)) != 0; } // Portable version of signbit. static bool isnegative(double x) { using namespace fmt::internal; - if (sizeof(signbit(x)) == sizeof(int)) + if (check(sizeof(signbit(x)) == sizeof(int))) return signbit(x); if (x < 0) return true; if (!isnotanumber(x)) return false; @@ -1006,11 +1015,6 @@ struct Not { enum { value = 0 }; }; template<> struct Not { enum { value = 1 }; }; -// A helper function to suppress bogus "conditional expression is constant" -// warnings. -template -inline T check(T value) { return value; } - // Makes an Arg object from any type. template class MakeValue : public Arg {