Repository navigation
Fix #15267 FN constVariablePointer when an alias of the pointer is moved with += or -= - #9069
Draft
autoantwort wants to merge 1 commit into
Draft
autoantwort wants to merge 1 commit into
autoantwort wants to merge 1 commit into
Conversation
…ved with += or -= Moving an alias of the pointer does not change the object, like assigning it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trac: https://trac.cppcheck.net/ticket/15267
Expected:
Variable 's' can be declared as pointer to const [constVariablePointer]. Actual: no warning. Since 4b66976 (#15042) symbolic values also go through pointer casts, so this now also hides a warning that was reported before (e.g.S* s = (S*)(*pp); *pp += 2;).Cause: the alias (
*pp) has the symbolic values, sofindVariableChanged()reports*pp += 2as a change of*s:isVariableChanged()returns true for the left operand of any assignment.isConstPointerVariable()already accepts the left side of a plain=, but not of+=/-=.Fix:
isConstPointerVariable()also accepts the left side of+=/-=when it is a pointer: moving the alias changes the pointer, not the pointee.*p += 2(which writes through the pointer) still prevents the warning (test added).Verification: new tests fail without the fix,
testrunnerpasses. On a large internal code base the only change vs main is one restored true positive.This PR was created by Claude Code (an AI coding agent) on behalf of @autoantwort.
🤖 Generated with Claude Code