Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

chrchr-github
Copy link
Collaborator

No description provided.

@@ -3293,7 +3293,7 @@ static ExprUsage getFunctionUsage(const Token* tok, int indirect, const Settings
} else if (ftok->str() == "{") {
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
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
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
Owner

@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 danmar:main Feb 27, 2024
64 checks passed
@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