Skip to content

fix #12944: False positive: uninitvar reported in lambda - #6975

Closed
ludviggunne wants to merge 3 commits into
cppcheck-opensource:mainfrom
ludviggunne:12944
Closed

fix #12944: False positive: uninitvar reported in lambda#6975
ludviggunne wants to merge 3 commits into
cppcheck-opensource:mainfrom
ludviggunne:12944

Conversation

@ludviggunne

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread test/testuninitvar.cpp Outdated
Comment thread test/testuninitvar.cpp
"{\n"
" int var;\n"
" auto lam = [&]() { int x = var; };\n"
" var = 5;\n"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume after your changes that no error will be written if var = 5; is removed?

It feels like a better fix would be in valueflow? I assume it "executes" the lambda when it is defined. It should probably skip the lambda first and then when lam() is called it can "execute" the lambda.

@ludviggunne
ludviggunne marked this pull request as draft November 19, 2024 08:07
@chrchr-github

Copy link
Copy Markdown
Collaborator

Superseded by #8237

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