diff --git a/src/corelib/global/qnumeric.h b/src/corelib/global/qnumeric.h index 2e13da4b850..bb2859031a6 100644 --- a/src/corelib/global/qnumeric.h +++ b/src/corelib/global/qnumeric.h @@ -8,6 +8,7 @@ #pragma qt_class(QtNumeric) #endif +#include #include #include #include @@ -334,7 +335,12 @@ template bool qMulOverflow(T v1, T *r) } template -constexpr inline T qAbs(const T &t) { return t >= 0 ? t : -t; } +constexpr inline T qAbs(const T &t) +{ + if constexpr (std::is_integral_v && std::is_signed_v) + Q_ASSERT(t != std::numeric_limits::min()); + return t >= 0 ? t : -t; +} namespace QtPrivate { template