Skip to content

Fix #13628 FP: accessMoved with ternary#8645

Open
francois-berder wants to merge 1 commit into
cppcheck-opensource:mainfrom
francois-berder:pr-13628
Open

Fix #13628 FP: accessMoved with ternary#8645
francois-berder wants to merge 1 commit into
cppcheck-opensource:mainfrom
francois-berder:pr-13628

Conversation

@francois-berder

Copy link
Copy Markdown
Collaborator

When std::move(x) is only in the true branch of a ternary operator, endOfFunctionCall was left pointing at the first token of the false branch, causing valueFlowForward to tag it as always-moved and report a spurious warning on the ? token.

Fix by advancing past the entire false-branch subtree using nextAfterAstRightmostLeaf before starting propagation.

When std::move(x) is only in the true branch of a ternary operator,
endOfFunctionCall was left pointing at the first token of the false
branch, causing valueFlowForward to tag it as always-moved and report
a spurious warning on the ? token.

Fix by advancing past the entire false-branch subtree using
nextAfterAstRightmostLeaf before starting propagation.

Signed-off-by: Francois Berder <fberder@outlook.fr>
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.

1 participant