From 6e053a7a5c71cb01f238c51ca98f3377c184cfb9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 1 Apr 2014 17:38:11 -0700 Subject: 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 --- src/qml/types/qqmldelegatemodel.cpp | 4 ++-- 1 file 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(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(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); -- cgit v1.2.3