I suspect that some of the FPs in our codebase result from the fact that cppcheck assumes that the return value of std::distance is always unsigned, see: https://github.com/danmar/cppcheck/blob/main/cfg/std.cfg line 7184
However it says here: https://en.cppreference.com/w/cpp/iterator/distance
"The number of increments needed to go from first to last. The value may be negative if random-access iterators are used and first is reachable from last (since C++11) "
Could you please check?
Thanks,
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I suspect that some of the FPs in our codebase result from the fact that cppcheck assumes that the return value of std::distance is always unsigned, see:
https://github.com/danmar/cppcheck/blob/main/cfg/std.cfg line 7184
However it says here:
https://en.cppreference.com/w/cpp/iterator/distance
"The number of increments needed to go from first to last. The value may be negative if random-access iterators are used and first is reachable from last (since C++11) "
Could you please check?
Thanks,
Martin
Thanks! I made a quick fix with e09e393503f760da00197ab777347ff562eb4e46