Skip to content

Commit 520147a

Browse files
Fix #13848 FP uninitStructMember with overloaded operator>> (danmar#7549)
1 parent 4bc359a commit 520147a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/checkuninitvar.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,9 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const Variable& var
796796

797797

798798
if (!membervar.empty()) {
799+
if (mTokenizer->isCPP() && Token::simpleMatch(tok->astParent(), ">>"))
800+
return true;
801+
799802
if (isMemberVariableAssignment(tok, membervar)) {
800803
checkRhs(tok, var, *alloc, number_of_if, membervar);
801804
return true;

test/testuninitvar.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4987,6 +4987,14 @@ class TestUninitVar : public TestFixture {
49874987
" return s.i;\n"
49884988
"}\n");
49894989
ASSERT_EQUALS("", errout_str());
4990+
4991+
checkUninitVar("struct S { int a; };\n" // #13848
4992+
"int f(std::istream& is) {\n"
4993+
" S s;\n"
4994+
" is >> s;\n"
4995+
" return s.a;\n"
4996+
"}\n");
4997+
ASSERT_EQUALS("", errout_str());
49904998
}
49914999

49925000
void uninitvar2_while() {

0 commit comments

Comments
 (0)