Skip to content

Fix #12459 FP uninitialized variable, pointer passed to constructor#6041

Merged
chrchr-github merged 1 commit intocppcheck-opensource:mainfrom
chrchr-github:chr_Fix12459
Feb 27, 2024
Merged

Fix #12459 FP uninitialized variable, pointer passed to constructor#6041
chrchr-github merged 1 commit intocppcheck-opensource:mainfrom
chrchr-github:chr_Fix12459

Conversation

@chrchr-github
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread lib/astutils.cpp
return indirect == 0 ? ExprUsage::Used : ExprUsage::Inconclusive;
} else if (ftok->variable() && ftok == ftok->variable()->nameToken()) { // variable init/constructor call
if (ftok->variable()->type() && ftok->variable()->type()->needInitialization == Type::NeedInitialization::True)
if (ftok->variable()->type() && ftok->variable()->type()->classScope && ftok->variable()->type()->classScope->numConstructors == 0)
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.

Will we still diagnose this case?

struct S {
    S(char*);
    int i;
};
void f() {
    char c;
    S s(&c);
}

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.

No. But if we did warn, it was by accident, since there is no argument checking at all.
That line was originally added in #5713, which is about POD types.

Copy link
Copy Markdown
Collaborator

@danmar danmar left a comment

Choose a reason for hiding this comment

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

lgtm

@chrchr-github chrchr-github merged commit 18583ca into cppcheck-opensource:main Feb 27, 2024
@chrchr-github chrchr-github deleted the chr_Fix12459 branch February 27, 2024 20:25
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