Hi, I found a false negative regarding the rule incorrectLogicOperator.
Cppcheck reports incorrectLogicOperator for the direct condition x >= 0 || x <= 10, because the disjunction is always true. However, if the two comparisons are stored in boolean temporaries first, cppcheck reports no warning even though the condition is semantically equivalent.
Hi, I found a false negative regarding the rule
incorrectLogicOperator.Cppcheck reports
incorrectLogicOperatorfor the direct conditionx >= 0 || x <= 10, because the disjunction is always true. However, if the two comparisons are stored in boolean temporaries first, cppcheck reports no warning even though the condition is semantically equivalent.Original seed program
Reproducing program
The condition
b1 || b2is equivalent tox >= 0 || x <= 10, which is always true for any integerx.Actual result
Cppcheck reports no
incorrectLogicOperatorwarning for the reproducing program.Expected result
Cppcheck should report
incorrectLogicOperatorfor the conditionb1 || b2.Verification
The issue was reproduced with:
Version: 2.21.0
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14943