Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Uninitialized variables: Fixed fp when initializing struct with funct…

…ion in loop body
  • Loading branch information...
commit 7fdaba43ed2034b326f053af9dc0764e72fd627b 1 parent 96a5429
@danmar authored
Showing with 10 additions and 0 deletions.
  1. +2 −0  lib/checkuninitvar.cpp
  2. +8 −0 test/testuninitvar.cpp
View
2  lib/checkuninitvar.cpp
@@ -1461,6 +1461,8 @@ bool CheckUninitVar::checkLoopBody(const Token *tok, const Variable& var, const
if (isMemberVariableUsage(tok, var.isPointer(), membervar))
usetok = tok;
+ else if (Token::Match(tok->previous(), "[(,] %var% [,)]"))
+ return true;
} else {
if (isVariableUsage(tok, var.isPointer(), _tokenizer->isCPP()))
usetok = tok;
View
8 test/testuninitvar.cpp
@@ -2731,6 +2731,14 @@ class TestUninitVar : public TestFixture {
"}");
ASSERT_EQUALS("", errout.str());
+ // for
+ checkUninitVar2("struct AB { int a; };\n"
+ "void f() {\n"
+ " struct AB ab;\n"
+ " while (x) { clear(ab); z = ab.a; }\n"
+ "}");
+ ASSERT_EQUALS("", errout.str());
+
// address of member
checkUninitVar2("struct AB { int a[10]; int b; };\n"
"void f() {\n"
Please sign in to comment.
Something went wrong with that request. Please try again.