Cppcheck 2.1 warns about a duplicate condition, even if the state of the object has changed in between:
struct Foo { int i{}; void nonconst() { ++i; } int GetI() const { return i; } void doIt() { if (GetI() == 0) nonconst(); if (GetI() == 0) // style: The if condition is the same as the previous if condition nonconst(); } }; int main() { Foo f; f.doIt(); return 0; }
Thanks! I can reproduce with cppcheck-2.0 but I can't reproduce with cppcheck-HEAD. So I hope this is fixed.
That would be nice! Currently, I am unable to test with HEAD myself.
Log in to post a comment.
Cppcheck 2.1 warns about a duplicate condition, even if the state of the object has changed in between:
Thanks! I can reproduce with cppcheck-2.0 but I can't reproduce with cppcheck-HEAD. So I hope this is fixed.
That would be nice! Currently, I am unable to test with HEAD myself.