cppcheck 1.90 is reporting an incorrect incorrectLogicOperator warning. The value of EE_E is incorrect.
enum_val_3.cpp:17:27: warning: Logical conjunction always evaluates to false: eeStart < num && num <= 3. [incorrectLogicOperator] return ((eeStart < num) && (num <= EE_E));
#include <iostream> using namespace std; const unsigned eeStart = 1000; enum MyEnum { EE_A = eeStart+1, EE_B, EE_C, EE_D, EE_E, }; bool myEnumCheck(unsigned num) { return ((eeStart < num) && (num <= EE_E)); } int main() { cout << "v1 is " << myEnumCheck(1003) << endl; cout << "v2 is " << myEnumCheck(99) << endl; cout << "Done" << endl; return 0; }
Thanks! I created this ticket: https://trac.cppcheck.net/ticket/9647
Log in to post a comment.
cppcheck 1.90 is reporting an incorrect incorrectLogicOperator warning. The value of EE_E is incorrect.
enum_val_3.cpp:17:27: warning: Logical conjunction always evaluates to false: eeStart < num && num <= 3. [incorrectLogicOperator]
return ((eeStart < num) && (num <= EE_E));
Thanks! I created this ticket: https://trac.cppcheck.net/ticket/9647