summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlist.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2013-10-14 18:13:14 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-19 15:31:17 +0200
commitdeb925b1b6dccec5c36a3d0a302fcb5ec58b040d (patch)
treea9aab9b3dfa083df7a6e6c5875c4edbb618c388b /src/corelib/tools/qlist.h
parent22c2d13406394077792c106ce1b60b3203aaf392 (diff)
Change an addition into a subtraction
This potentially resolves the long-standing warning from GCC: assuming signed overflow does not occur when assuming that (X + c) < X is always false GCC prints the warning to warn people that you can't check for overflow with signed integers by doing that (signed integers don't overflow in the standard). If we change this to X < X - c, there's no overflow. Task-number: QTBUG-33314 Change-Id: I5b166610a39559ec7b03c4c31ee5999efefa0c06 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools/qlist.h')
-rw-r--r--src/corelib/tools/qlist.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index b795bbc86e..333ce72849 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -639,7 +639,7 @@ inline void QList<T>::move(int from, int to)
template<typename T>
Q_OUTOFLINE_TEMPLATE QList<T> QList<T>::mid(int pos, int alength) const
{
- if (alength < 0 || pos + alength > size())
+ if (alength < 0 || pos > size() - alength)
alength = size() - pos;
if (pos == 0 && alength == size())
return *this;