Skip to content

Conversation

@chrchr-github
Copy link
Collaborator

No description provided.

ASSERT_EQUALS("", errout_str());

check("struct S {\n" // #14392
" bool g() const { return m; }\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make sure it doesnt warn when doing bool g() const { return true; }.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, this is a different warning.

@sonarqubecloud
Copy link

@chrchr-github
Copy link
Collaborator Author

This looks like a true positive:

FirstChild() &&

We don't catch this instance yet:
const bool pointerDereference = (tok->astOperand1() && tok->astOperand1()->isUnaryOp("*")) ||

" }\n"
" return false;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:6:12] -> [test.cpp:7:21]: (style) Condition 's.g()' is always true [knownConditionTrueFalse]\n", errout_str());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems unfortunate to say that "Condition" is always true. The RHS in a assignment is not a "Condition".

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if g() returns an int instead? That is not "true" or "false".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants