Restore warning for #14392 - #8859
chrchr-github wants to merge 2 commits into
Conversation
| " return false;\n" | ||
| "}\n"); | ||
| TODO_ASSERT_EQUALS("[test.cpp:6:12] -> [test.cpp:7:21]: (style) Assigned value 's.g()' is always true [knownConditionTrueFalse]\n", "", errout_str()); | ||
| ASSERT_EQUALS("[test.cpp:6:12] -> [test.cpp:8:16]: (style) Return value 'b' is always true [knownConditionTrueFalse]\n", errout_str()); |
There was a problem hiding this comment.
I am not sure. what is the motivation to warn here?
this checker is about known conditions from the start. I documented my understanding of this in man/checkers/knownConditionTrueFalse.md. If that motivation/description can be improved feel free to do it.
I feel that such return value warning should be a separate checker as you said here:
#8853 (comment)
There was a problem hiding this comment.
The motivation still comes from https://trac.cppcheck.net/ticket/14392
We warn for return s.g();, so we should also warn if the result is stored in an intermediate variable.
There was a problem hiding this comment.
14392 does not contain a explanation.
I want to have an explanation for what the checker is looking for and why it warns.
The man/checkers/knownConditionTrueFalse.md I added has an explanation for when we warn for conditions that are always true and false that leads to redundant code. But it does not explain why we warn for return statements.. if the return statement is still needed I don't understand why we should warn and I have not got any explanation for that.
No description provided.