It should (obviously) return (x - 1) for x positive, zero for x == 0.
But cppcheck (online demo) complains: [test.cpp:3]: (style) Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
Cppcheck 2.11 on my project says: style: Same expression on both sides of '-'. [duplicateExpression]
I think cppcheck overlooks the double negation "!!".
Best Regards Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
lets' have following routine:
It should (obviously) return (x - 1) for x positive, zero for x == 0.
But cppcheck (online demo) complains: [test.cpp:3]: (style) Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
Cppcheck 2.11 on my project says: style: Same expression on both sides of '-'. [duplicateExpression]
I think cppcheck overlooks the double negation "!!".
Best Regards Martin
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11820