From 28f1eb6c838529675613f05f990255d3b0a22f3a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 14 Sep 2023 18:22:12 +0200 Subject: [PATCH] tst_QGlobal: work around ubsan issue in toString(qint128) Found a problem on GCC 9.4 where asan/ubsan seems to break std::numeric_limits::min(): runtime error: negation of 0x80000000000000000000000000000000 cannot be represented in type '__int128'; cast to an unsigned type to negate this value to itself This is the -i _after_ we've already checked for ::min() two lines above. It works with Q_INT128_MIN, though, so use that. Pick-to: 6.6 Change-Id: I778980baf4e7eea9f8de06697d792241314acacd Reviewed-by: Ivan Solovev Reviewed-by: Edward Welbourne --- tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 6da78555cb8..b7c45b64808 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -37,7 +37,7 @@ namespace detail { template <> char *toString(const qint128 &i) { - if (i == std::numeric_limits::min()) // -i is not representable, hardcode: + if (i == Q_INT128_MIN) // -i is not representable, hardcode: return qstrdup("-170141183460469231731687303715884105728"); std::array buffer; auto dst = detail::i128ToStringHelper(buffer, i < 0 ? -i : i);