summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlocale.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qlocale.cpp')
-rw-r--r--src/corelib/tools/qlocale.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 723e63114d..c85dcb4358 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -3151,11 +3151,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) {