Skip to content

Fix #12083 FN passedByValue with usage in ternary#5575

Merged
chrchr-github merged 13 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_Fix12083
Oct 31, 2023
Merged

Fix #12083 FN passedByValue with usage in ternary#5575
chrchr-github merged 13 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_Fix12083

Conversation

@chrchr-github

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread test/cfg/std.cpp Outdated
Comment thread test/cfg/std.cpp
}

// TODO cppcheck-suppress passedByValue
// cppcheck-suppress passedByValue

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This seems to be a shortcoming of canBeConst().

Comment thread test/testother.cpp
" static int& i = x[0];\n"
" return i;\n"
"}");
ASSERT_EQUALS("", errout.str());

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Here we show a warning although i also needs to be changed. Acceptable?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No sure.

But it looks like code which applies to the suggested https://trac.cppcheck.net/ticket/11565.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We actually detect the a danglingReference in the test case.

@chrchr-github

chrchr-github commented Oct 20, 2023

Copy link
Copy Markdown
Collaborator Author

Supersedes #5574
#5579 should be merged first. ✅

@chrchr-github chrchr-github marked this pull request as ready for review October 20, 2023 13:44
@chrchr-github chrchr-github merged commit c2d5aef into cppcheck-opensource:main Oct 31, 2023
@chrchr-github chrchr-github deleted the chr_Fix12083 branch October 31, 2023 15:12
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.

2 participants