The size is increasing along with the loop because items are being appended to it so it looks like the size is being checked too soon.
error: containerOutOfBounds - Out of bounds access in 'labelList.at', if 'labelList' size is 1 and 'i' is 3
#include <QHBoxLayout> #include <QLabel> #include <QList> #include <QWidget> QList<QLabel*> containerOutOfBoundsFalsePositiveExample(QWidget* parent) { QList<QLabel*> labelList; QHBoxLayout* horizontalLayout = new QHBoxLayout(parent); for(int i = 0; i < 4; ++i) { labelList.append(new QLabel(parent)); horizontalLayout->insertWidget(i, labelList.at(i), Qt::AlignCenter); } return labelList; }
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/10556
Log in to post a comment.
The size is increasing along with the loop because items are being appended to it so it looks like the size is being checked too soon.
error: containerOutOfBounds - Out of bounds access in 'labelList.at', if 'labelList' size is 1 and 'i' is 3
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/10556