Skip to content

Fix #13628 FP: accessMoved with ternary#8645

Merged
chrchr-github merged 2 commits into
cppcheck-opensource:mainfrom
francois-berder:pr-13628
Jun 18, 2026
Merged

Fix #13628 FP: accessMoved with ternary#8645
chrchr-github merged 2 commits 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>
Comment thread lib/valueflow.cpp Outdated
@chrchr-github chrchr-github merged commit 93bc251 into cppcheck-opensource:main Jun 18, 2026
70 checks passed
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