Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/checkuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,8 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const Variable& var
}

// assume that variable is assigned
return true;
if (!Token::simpleMatch(tok->astParent(), "<<"))
return true;
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/testuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,13 @@ class TestUninitVar : public TestFixture {
"}");
ASSERT_EQUALS("[test.cpp:3:17]: (error) Uninitialized variable: p [legacyUninitvar]\n", errout_str());
}

checkUninitVar("void f() {\n" // #13908
" int* i = new int;\n"
" std::cout << i << \", \" << *i;\n"
" delete i;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3:32]: (error) Memory is allocated but not initialized: i [uninitdata]\n", errout_str());
}

// #8494 : Overloaded & operator
Expand Down
Loading