containerOutOfBounds - Out of bounds access in 'totals[index++]', if 'totals' size is 3 and 'index++' is 5
class ExampleClass { public: void SetValue(int value) { Value = value; } private: int Value; }; QVector<ExampleClass*> GetVector() { int index = 0; QVector<ExampleClass*> values; values.reserve(3); values.push_back(new ExampleClass()); values[index++].SetValue(1000); values.push_back(new ExampleClass()); values[index++].SetValue(2000); values.push_back(new ExampleClass()); values[index++].SetValue(3000); return values; }
It works fine if it is a vector of ints but gets confused once you try manipulating class values.
it also works with integers instead of index++
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/12731
Log in to post a comment.
containerOutOfBounds - Out of bounds access in 'totals[index++]', if 'totals' size is 3 and 'index++' is 5
It works fine if it is a vector of ints but gets confused once you try manipulating class values.
it also works with integers instead of index++
Last edit: Steve Albright 2024-05-14
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/12731