Menu

cfg: FPs due to wrong std::distance assumed return type

Martin
2021-03-31
2021-04-03
  • Martin

    Martin - 2021-03-31

    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

     
  • Daniel Marjamäki

    Thanks! I made a quick fix with e09e393503f760da00197ab777347ff562eb4e46

     

Log in to post a comment.