diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-04-01 17:38:11 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-02 23:49:11 +0200 |
commit | 6e053a7a5c71cb01f238c51ca98f3377c184cfb9 (patch) | |
tree | 38d2670114c8a304188c2cc860948664af7c0b67 | |
parent | c1d2bcff3dededa5b560713f4fd4874a023c43a2 (diff) |
Work around warning by GCC 4.8 with -O3 about array out of bounds
qqmldelegatemodel.cpp:1140:53: error: array subscript is above array bounds [-Werror=array-bounds]
attached->m_currentIndex[i] += deltas[i];
^
qqmldelegatemodel.cpp:2009:29: error: array subscript is above array bounds [-Werror=array-bounds]
m_currentIndex[i] = m_previousIndex[i] = incubationTask->index[i];
^
I can't tell how the count can be higher than MaximumGroupCount. Either
GCC is seeing something I'm not while inlining multiple functions, or
it's just getting lost. If it's the former case, this is change could be
a fix, but it's probably the wrong type of fix. If it's the latter,
we're just throwing the inliner a curve ball and it just stops
complaining.
Change-Id: I7907074005f5327a8592f47d72a4e79f9c6cd5ff
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 910cec9087..be479ee17d 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1136,7 +1136,7 @@ static void incrementIndexes(QQmlDelegateModelItem *cacheItem, int count, const incubationTask->index[i] += deltas[i]; } if (QQmlDelegateModelAttached *attached = cacheItem->attached) { - for (int i = 1; i < count; ++i) + for (int i = 1; i < qMin<int>(count, Compositor::MaximumGroupCount); ++i) attached->m_currentIndex[i] += deltas[i]; } } @@ -2005,7 +2005,7 @@ QQmlDelegateModelAttached::QQmlDelegateModelAttached( { QQml_setParent_noEvent(this, parent); if (QQDMIncubationTask *incubationTask = m_cacheItem->incubationTask) { - for (int i = 1; i < m_cacheItem->metaType->groupCount; ++i) + for (int i = 1; i < qMin<int>(m_cacheItem->metaType->groupCount, Compositor::MaximumGroupCount); ++i) m_currentIndex[i] = m_previousIndex[i] = incubationTask->index[i]; } else { QQmlDelegateModelPrivate * const model = QQmlDelegateModelPrivate::get(m_cacheItem->metaType->model); |