Skip to content

Fix #12287 FP uninitvar when passing address to function#5899

Merged
orbitcowboy merged 2 commits intocppcheck-opensource:mainfrom
chrchr-github:chr_Fix12287
Jan 19, 2024
Merged

Fix #12287 FP uninitvar when passing address to function#5899
orbitcowboy merged 2 commits intocppcheck-opensource:mainfrom
chrchr-github:chr_Fix12287

Conversation

@chrchr-github
Copy link
Copy Markdown
Collaborator

No description provided.

@orbitcowboy orbitcowboy merged commit e5d7376 into cppcheck-opensource:main Jan 19, 2024
@chrchr-github chrchr-github deleted the chr_Fix12287 branch January 19, 2024 21:25
Comment thread test/testuninitvar.cpp
" return n;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:1]: (warning) Uninitialized variable: i\n", errout.str());
ASSERT_EQUALS("", errout.str());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be caught be ValueFlow.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Well, it is, and then we bail because we don't have a function isVariableWrittenBeforeReadInFunctionCall().
Please feel free to improve on this fix.

Comment thread test/testuninitvar.cpp
" bool b;\n"
" f(&b);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There should be a valueflow test to make sure the valueflow for p in *p = true is not set to an uninitialized value.

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