diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index f318ec8316a..0d46506c764 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -4933,9 +4933,9 @@ QString QLocale::formattedDataSize(qint64 bytes, int precision, DataSizeFormats if (!bytes) { power = 0; } else if (format & DataSizeBase1000) { - power = int(std::log10(qAbs(bytes)) / 3); + power = int(std::log10(QtPrivate::qUnsignedAbs(bytes)) / 3); } else { // Compute log2(bytes) / 10: - power = int((63 - qCountLeadingZeroBits(quint64(qAbs(bytes)))) / 10); + power = int((63 - qCountLeadingZeroBits(QtPrivate::qUnsignedAbs(bytes))) / 10); base = 1024; } // Only go to doubles if we'll be using a quantifier: diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index 4c0dfe322f3..b8cacda937f 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -3970,9 +3970,7 @@ void tst_QLocale::formattedDataSize_data() ROWQ("IEC-1235k", 2, 1234567, "1", "18 Mi"); ROWQ("IEC-1374k", 2, 1374744, "1", "31 Mi"); ROWQ("IEC-1234M", 2, 1234567890, "1", "15 Gi"); - if (false) { // hits UB ROWQ("IEC-min", 2, min64, "-8", "00 Ei"); - } ROWQ("IEC-max", 2, max64, "8", "00 Ei"); } { @@ -3986,9 +3984,7 @@ void tst_QLocale::formattedDataSize_data() ROWQ("Trad--1235k", 2, -1234567, "-1", "18 M"); ROWQ("Trad-1374k", 2, 1374744, "1", "31 M"); ROWQ("Trad-1234M", 2, 1234567890, "1", "15 G"); - if (false) { // hits UB ROWQ("Trad-min", 2, min64, "-8", "00 E"); - } ROWQ("Trad-max", 2, max64, "8", "00 E"); } { @@ -4001,9 +3997,7 @@ void tst_QLocale::formattedDataSize_data() ROWQ("Decimal-1374k", 2, 1374744, "1", "37 M"); ROWQ("Decimal-1234M", 2, 1234567890, "1", "23 G"); ROWQ("Decimal--1234M", 2, -1234567890, "-1", "23 G"); - if (false) { // hits UB ROWQ("Decimal-min", 2, min64, "-9", "22 E"); - } ROWQ("Decimal-max", 2, max64, "9", "22 E"); } #undef ROWQ