diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 14 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_tools.cpp | 5 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_tools_p.h | 1 |
3 files changed, 9 insertions, 11 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 9a46018ede..ebda40bd8d 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3149,11 +3149,15 @@ QString QLocaleData::longLongToString(const QChar zero, const QChar group, negative = false; // neither are negative numbers } - QString num_str; - if (base == 10) - num_str = qlltoa(l, base, zero); - else - num_str = qulltoa(l, base, zero); +QT_WARNING_PUSH + /* "unary minus operator applied to unsigned type, result still unsigned" */ +QT_WARNING_DISABLE_MSVC(4146) + /* + Negating std::numeric_limits<qlonglong>::min() hits undefined behavior, so + taking an absolute value has to cast to unsigned to change sign. + */ + QString num_str = qulltoa(negative ? -qulonglong(l) : qulonglong(l), base, zero); +QT_WARNING_POP uint cnt_thousand_sep = 0; if (flags & ThousandsGroup && base == 10) { diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp index 3e4f37501e..4d969a4723 100644 --- a/src/corelib/tools/qlocale_tools.cpp +++ b/src/corelib/tools/qlocale_tools.cpp @@ -456,11 +456,6 @@ QString qulltoa(qulonglong l, int base, const QChar _zero) return QString(reinterpret_cast<QChar *>(p), 65 - (p - buff)); } -QString qlltoa(qlonglong l, int base, const QChar zero) -{ - return qulltoa(l < 0 ? -l : l, base, zero); -} - QString &decimalForm(QChar zero, QChar decimal, QChar group, QString &digits, int decpt, int precision, PrecisionMode pm, diff --git a/src/corelib/tools/qlocale_tools_p.h b/src/corelib/tools/qlocale_tools_p.h index 6133f67add..742abb4957 100644 --- a/src/corelib/tools/qlocale_tools_p.h +++ b/src/corelib/tools/qlocale_tools_p.h @@ -83,7 +83,6 @@ void doubleToAscii(double d, QLocaleData::DoubleForm form, int precision, char * bool &sign, int &length, int &decpt); QString qulltoa(qulonglong l, int base, const QChar _zero); -QString qlltoa(qlonglong l, int base, const QChar zero); Q_CORE_EXPORT QString qdtoa(qreal d, int *decpt, int *sign); enum PrecisionMode { |