diff --git a/lib/astutils.cpp b/lib/astutils.cpp index a242352a879..b3a656bdf02 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2571,7 +2571,7 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings *settings, tok2 = skipRedundantPtrOp(tok2, tok2->astParent()); if (tok2->astParent() && tok2->astParent()->isAssignmentOp()) { - if ((indirect == 0 || tok2 != tok) && tok2 == tok2->astParent()->astOperand1()) + if (((indirect == 0 || tok2 != tok) || (indirect == 1 && tok2->str() == ".")) && tok2 == tok2->astParent()->astOperand1()) return true; // Check if assigning to a non-const lvalue const Variable * var = getLHSVariable(tok2->astParent()); diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index cd430663354..2fe099b08f5 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -6406,6 +6406,14 @@ class TestUninitVar : public TestFixture { " f(&b);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + valueFlowUninit("struct S { int x; };\n" // #12394 + "int f() {\n" + " struct S s[1];\n" + " s->x = 0;\n" + " return s[0].x;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value