Skip to content

Commit 2807d6e

Browse files
Fix #14708 FP uninitialized variable reported for array decay to pointer in initializer list (#8531)
1 parent 6c73feb commit 2807d6e

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

lib/checkuninitvar.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,6 @@ const Token* CheckUninitVar::isVariableUsage(const Token *vartok, const Library&
12621262
const Token *parent = valueExpr->astParent();
12631263
while (Token::simpleMatch(parent, ","))
12641264
parent = parent->astParent();
1265-
if (Token::simpleMatch(parent, "{"))
1266-
return valueExpr;
12671265
const int use = isFunctionParUsage(valueExpr, library, pointer, alloc, indirect);
12681266
return (use>0) ? valueExpr : nullptr;
12691267
}

test/testuninitvar.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7935,6 +7935,12 @@ class TestUninitVar : public TestFixture {
79357935
" (*fp[0])();\n"
79367936
"}");
79377937
ASSERT_EQUALS("", errout_str());
7938+
7939+
checkUninitVar("void f() {\n" // #14708
7940+
" int a[1], b[1];\n"
7941+
" int* c[2]{ a, b };\n"
7942+
"}");
7943+
ASSERT_EQUALS("", errout_str());
79387944
}
79397945

79407946
void isVariableUsageDerefValueflow()

0 commit comments

Comments
 (0)