diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 66954f066..13ae85df4 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3704,8 +3704,7 @@ static bool isVariableExpression(const Token* tok) return isVariableExpression(tok->astOperand1()) && isVariableExpression(tok->astOperand2()); if (Token::simpleMatch(tok, "[")) - return isVariableExpression(tok->astOperand1()) && - tok->astOperand2() && tok->astOperand2()->hasKnownIntValue(); + return isVariableExpression(tok->astOperand1()); return false; } diff --git a/test/testother.cpp b/test/testother.cpp index 3d9f24be6..829265a37 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -11053,6 +11053,20 @@ private: " if (g(k(i))) {}\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + // #11889 + check("struct S {\n" + " int a[5];\n" + " void f(int i);\n" + "}\n" + "void g(int);\n" + "void S::f(int i) {\n" + " if (a[i] == 1) {\n" + " a[i] = 0;\n" + " g(a[i]);\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void knownArgumentHiddenVariableExpression() {