This cropped up in v2.2. There is an early return if both containers are empty, but OldFormat can still be false.
#include <string> #include <vector> bool foo(bool b) { return !b; } bool thud(const std::vector<std::wstring>& Arr, const std::wstring& Str) { if (Arr.empty() && Str.empty()) return false; bool OldFormat = Arr.empty() && !Str.empty(); // style: Condition 'OldFormat' is always true [knownConditionTrueFalse] if (OldFormat) return foo(OldFormat); // no warning without this call (e.g. just return true;) return false; } int main() { std::vector<std::wstring> Arr; std::wstring Str; return thud(Arr, Str) ? 1 : 0; }
This is still reported in 2.3, but I think I have seen a similar ticket somewhere.
oops sorry no response. let me know if you find the ticket or not..
Probably I remembered this one: https://trac.cppcheck.net/ticket/10088 But that's not quite the same issue, so a new ticket might be in order.
Thanks! I created https://trac.cppcheck.net/ticket/10134
Log in to post a comment.
This cropped up in v2.2. There is an early return if both containers are empty, but OldFormat can still be false.
This is still reported in 2.3, but I think I have seen a similar ticket somewhere.
oops sorry no response. let me know if you find the ticket or not..
Probably I remembered this one: https://trac.cppcheck.net/ticket/10088
But that's not quite the same issue, so a new ticket might be in order.
Thanks! I created https://trac.cppcheck.net/ticket/10134