Fixed #4737 (False positive: Uninitialized variable 'do_something(&((char*)&var)[0],1);')
This commit is contained in:
parent
42068a3d60
commit
44cb070e13
|
@ -1549,7 +1549,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, bool cpp
|
|||
return false; // address of
|
||||
if (tok2 && tok2->str() == ")")
|
||||
tok2 = tok2->link()->previous();
|
||||
if (Token::Match(tok2,") ( %type% *| ) &") && tok2->tokAt(2)->varId() == 0)
|
||||
if (Token::Match(tok2,"[()] ( %type% *| ) &") && tok2->tokAt(2)->varId() == 0)
|
||||
return false; // cast
|
||||
while (tok2 && tok2->str() == "(")
|
||||
tok2 = tok2->previous();
|
||||
|
|
|
@ -2023,6 +2023,12 @@ private:
|
|||
"}", "test.c", false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar2("void f() {\n" // #4737 - weird cast.
|
||||
" int x;\n"
|
||||
" do_something(&((char*)&x)[0], 1);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// using uninit var in condition
|
||||
checkUninitVar2("void f(void) {\n"
|
||||
" int x;\n"
|
||||
|
|
Loading…
Reference in New Issue