Fix #11890 FP uninitvar for address taken in init list (#5360)

This commit is contained in:
chrchr-github 2023-08-24 10:35:33 +02:00 committed by GitHub
parent 5a7c7b9b5a
commit 4654b6561b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -3149,7 +3149,7 @@ static ExprUsage getFunctionUsage(const Token* tok, int indirect, const Settings
} else if (ftok->isControlFlowKeyword()) {
return ExprUsage::Used;
} else if (ftok->str() == "{") {
return ExprUsage::Used;
return indirect == 0 ? ExprUsage::Used : ExprUsage::Inconclusive;
} else {
const bool isnullbad = settings->library.isnullargbad(ftok, argnr + 1);
if (indirect == 0 && astIsPointer(tok) && !addressOf && isnullbad)

View File

@ -6197,6 +6197,12 @@ private:
" x = i;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: i\n", errout.str());
valueFlowUninit("void f() {\n" // #11890
" int x;\n"
" int* a[] = { &x };\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value