return true; is readable, return static_cast<int>(1); not so much.
Maybe we should move the discussion to the PR. I don't know if it will be merged as-is.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
with
98b2fd8151897274bfacf5cf151068536c9be3c5
there are a number of new FPs:
Could you please check?
Thanks,
Martin
Thanks, should be fixed by https://github.com/danmar/cppcheck/pull/4419
Regarding that pull request, why is
(line 4333 in testcondítion.cpp)
a correct finding? There's no condition in
Same for
Last edit: Martin 2022-08-30
Because those statements are equivalent to
return false/true;
respectively (if the return type isbool
)?But false/true aren't conditions, but boolean values? What's wrong with "return true"?
return true;
is readable,return static_cast<int>(1);
not so much.Maybe we should move the discussion to the PR. I don't know if it will be merged as-is.
The PR is merged now, I'd still argue though that if you actually want have warnings like (with the current head)
for
then at least the wording of the message should be changed. "condition" and "boolean value" cannot be used completely interchangeably.