I have encountered a false positive in Cppcheck 2.13.0
Severity: style Summary: Condition '++counter==0' is always false
Example code that triggers the false positive:
#include <iostream> #include <limits> void incr(unsigned & counter) { std::cout << "Incrementing counter. Curr value: " << counter << '\n'; if (++counter == 0) { std::cout << "Condition '++counter == 0' is true\n"; } std::cout << "Value after increment: " << counter << '\n'; } int main() { unsigned counter {}; incr(counter); counter = std::numeric_limits<unsigned>::max(); incr(counter); }
Looks like an instance of this issue: https://trac.cppcheck.net/ticket/10616
Log in to post a comment.
I have encountered a false positive in Cppcheck 2.13.0
Severity: style
Summary: Condition '++counter==0' is always false
Example code that triggers the false positive:
Looks like an instance of this issue: https://trac.cppcheck.net/ticket/10616