Bill Torpey - 2016-04-14

I've noticed some differences in output depending on the --std= parameter defined, and am curious (a) how they interact, and (b) whether it is possible to get an "inclusive" set of warnings in a single invocation of cppcheck.

Specifically, when run with "--std=c++03", I see the following warning:
(performance) Possible inefficient checking for 'std::list' emptiness.

This is triggered by code checking for "size() == 0", rather than "empty()".

With "--std=c++11" this warning disappears. That makes sense (sort of), since C++11 specifically mandates that size() is O(1).

However, gcc versions < 5 apparently don't honor that constraint (because it would break ABI compatability). There's a bit of a kerfuffle on the intertubes about that, but regardless of one's position on the issue, it would be nice if cppcheck did "the right thing" and warned about that construct.

In my case, I'm working on a couple of large-ish codebases that are currently on C++03 (so I'd like to see those warnings), but which we're planning to port to C++11 (so I'd like to see those warnings as well).

I've tried specifying both (as well as --std=posix, just to be as clean as possible), and it appears that the "--std=c++11" setting trumps "--std=c++03" and so disables this specific warning (and possibly others?)

Any suggestions would be much appreciated.

P.S. Is there a way to get an email notification when this thread is updated? I was kind of expecting that, but I don't seem to get them ...