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>usingnamespacestd;constunsignedeeStart=1000;enumMyEnum{EE_A=eeStart+1,EE_B,EE_C,EE_D,EE_E,};boolmyEnumCheck(unsignednum){return((eeStart<num)&&(num<=EE_E));}intmain(){cout<<"v1 is "<<myEnumCheck(1003)<<endl;cout<<"v2 is "<<myEnumCheck(99)<<endl;cout<<"Done"<<endl;return0;}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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