Fix #15062 Wrong varid for shadowed member in initializer list after braced init list argument (FP uninitMemberVar, selfInitialization, functionStatic) - #8885
Open
autoantwort wants to merge 1 commit into
Conversation
…braced init list argument (FP uninitMemberVar, selfInitialization, functionStatic)
In setVarIdPass1 a '{' inside a constructor initializer list was only
recognized as part of an argument if it was preceded by a name, '>',
'>>' or '('. A braced init list that is not the first argument, e.g.
x(f(0, {0})), or a nested one, e.g. x(f(0, {{1}, 2})), was treated as
the start of the constructor body. As a result the parameter scope was
not left correctly, so the member in a following p(p) got the varid of
the parameter, and the parameter varid leaked into later functions.
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.
In
setVarIdPass1a{inside a constructor initializer list was only treated as part of an argument when preceded by%name%|>|>>|(. For a braced init list that is not the first argument (x(f(0, {0}))) or a nested one (x(f(0, {{1}, 2}))), the{was taken as the start of the constructor body. The parameter scope was then not left correctly: a followingp(p)got the parameter's varid for the member, and the parameter varid leaked into later functions such asint T::g() { return *p; }.This caused false positives
uninitMemberVar,selfInitializationandfunctionStatic.The fix also accepts
,and{before the{, and}after the matching}.🤖 Generated with Claude Code