struct Bar { bool foo() const { return mFooIt != mFoo(); } QVector<int> mFoo; QVector<int>::iterator mFooIt; }; clazy reports: => Mixing iterators with const_iterators while technically correct, it's quite useless I think. This code works fine and is safe - maybe the comparison should check whether `const Foo::iterator` and `Foo::const_iterator` are compared, and if so don't emit the warning? clazy version: 1.5 clang version: 7.0.1
even adding an explicit static_cast<> to const_iterator warns: warning: Mixing iterators with const_iterators [-Wclazy-strict-iterators] return static_cast<decltype(mFoo)::const_iterator>(mFooIt) != mFoo.end();
Git commit 145e7b6578e690f1aacc250e0cadb8fcfdbb281e by Sergio Martins. Committed on 15/02/2019 at 18:45. Pushed by smartins into branch 'master'. strict-iterators: Don't warn when comparing against an iterator member var It won't detach the container M +17 -0 src/checks/level0/strict-iterators.cpp M +11 -0 tests/strict-iterators/main.cpp https://commits.kde.org/clazy/145e7b6578e690f1aacc250e0cadb8fcfdbb281e