Skip to content

Fix #2062 FN variable scope can be reduced (class instance)#7885

Merged
chrchr-github merged 3 commits intodanmar:mainfrom
chrchr-github:chr_2062
Oct 14, 2025
Merged

Fix #2062 FN variable scope can be reduced (class instance)#7885
chrchr-github merged 3 commits intodanmar:mainfrom
chrchr-github:chr_2062

Conversation

@chrchr-github
Copy link
Copy Markdown
Collaborator

No description provided.

@firewave
Copy link
Copy Markdown
Collaborator

Did you just move the code or did you also make some adjustments?

@chrchr-github
Copy link
Copy Markdown
Collaborator Author

Did you just move the code or did you also make some adjustments?

Just moved it.

@firewave
Copy link
Copy Markdown
Collaborator

And https://trac.cppcheck.net/ticket/14194 is not yet fixed by this? (If not I would be fine with a different PR addressing it).

@chrchr-github
Copy link
Copy Markdown
Collaborator Author

And https://trac.cppcheck.net/ticket/14194 is not yet fixed by this? (If not I would be fine with a different PR addressing it).

That one probably needs to be handled at the library level, or with some hard-coding for templates like std::pair.

@firewave
Copy link
Copy Markdown
Collaborator

That one probably needs to be handled at the library level, or with some hard-coding for templates like std::pair.

Since those are detected as "used" there should also be logic in that check which can be leveraged by the scope check.

@chrchr-github
Copy link
Copy Markdown
Collaborator Author

Since those are detected as "used" there should also be logic in that check which can be leveraged by the scope check.

std.cfg has <check>std::pair</check> , which leads to an unusedVariable FP for e.g. std::pair<T, U> p; (unknown types which might have side effects).

@sonarqubecloud
Copy link
Copy Markdown

@firewave
Copy link
Copy Markdown
Collaborator

std.cfg has <check>std::pair</check> , which leads to an unusedVariable FP for e.g. std::pair<T, U> p; (unknown types which might have side effects).

Ah - I did not test that. I did test it with user structs though.

@chrchr-github chrchr-github merged commit 7ca4556 into danmar:main Oct 14, 2025
54 checks passed
@chrchr-github chrchr-github deleted the chr_2062 branch October 14, 2025 06:50
@chrchr-github
Copy link
Copy Markdown
Collaborator Author

std.cfg has <check>std::pair</check> , which leads to an unusedVariable FP for e.g. std::pair<T, U> p; (unknown types which might have side effects).

Ah - I did not test that. I did test it with user structs though.

See https://trac.cppcheck.net/ticket/14201

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.

3 participants