Currently clazy throws an incorrect warning with the detaching-member test when a non-const method is called. For instance, list[1]->someNonConstMethod(); is incorrectly throwing the detach warning.
the warning is because of [1] no ?
yes, but in this case there's no way around calling the detaching [] operator
you can use .at(0), which doesn't detach: #include <QVector> #include <QDebug> struct T { void nonConst() { qDebug() << "T::nonConst"; } }; int main() { QVector<T*> vec = {new T()}; vec.at(0)->nonConst(); return 0; }
however for values instead of pointers you're correct
Yes - that's what I was referring to (values). Sorry, should have made that clearer to begin with!
...And I also just realised my example was very poorly chosen ;)
Git commit a85e4e1b9da90970d6270cb2674aa41eb0bbe933 by Sergio Martins. Committed on 15/12/2015 at 11:23. Pushed by smartins into branch 'master'. detaching-member: Fix false positive When calling m_listOfValues[0].nonConstMethod() we can't use .at() M +11 -1 checks/detachingmember.cpp M +1 -1 tests/detaching-member/main.cpp M +1 -1 tests/detaching-member/main.cpp.expected http://commits.kde.org/clazy/a85e4e1b9da90970d6270cb2674aa41eb0bbe933