Hi,
after the latest commit https://github.com/danmar/cppcheck/commit/e62cdbb6648248e6008039bdfd8c7faf02875431 new FPs show up like:
void foo() { auto referenceTime = a.getUnixTimestamp(); auto triggerTime = b.getUnixTimestamp(); if(triggerTime < referenceTime) { auto diff = referenceTime - triggerTime; if(diff < 1) { bar(); } } }
->
/home/user/Desktop/21-08-20.cpp:8:21: style: Condition 'diff<1' is always true [knownConditionTrueFalse] if(diff < 1) ^ /home/user/Desktop/21-08-20.cpp:5:25: note: Assuming that condition 'triggerTime<referenceTime' is not redundant if(triggerTime < referenceTime) ^ /home/user/Desktop/21-08-20.cpp:7:39: note: Assignment 'diff=referenceTime-triggerTime', assigned value is less than 0 auto diff = referenceTime - triggerTime; ^ /home/user/Desktop/21-08-20.cpp:8:21: note: Condition 'diff<1' is always true if(diff < 1) ^ /home/user/Desktop/21-08-20.cpp:1:0: style: The function 'foo' is never used. [unusedFunction] ^
I think the finding should be 'diff<1' is always false, rather than true.
Could you please check?
Thanks, Martin
This is fixed with: https://github.com/danmar/cppcheck/pull/3411
Log in to post a comment.
Hi,
after the latest commit
https://github.com/danmar/cppcheck/commit/e62cdbb6648248e6008039bdfd8c7faf02875431
new FPs show up like:
->
I think the finding should be 'diff<1' is always false, rather than true.
Could you please check?
Thanks,
Martin
This is fixed with:
https://github.com/danmar/cppcheck/pull/3411