diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 1beb26ea5..07e90a25e 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -673,7 +673,7 @@ private: bailouts.insert(tok2->varId()); // array initialization.. - if (Token::Match(tok2->previous(), "[,(] %var% +")) + if (Token::Match(tok2->previous(), "[,(] %var% [+-]")) { // if var is array, bailout for (std::list::const_iterator it = checks.begin(); it != checks.end(); ++it) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index a45e9fa83..0d2c3ffc8 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -879,6 +879,14 @@ private: " s = y[0]*y[1];\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar("void foo()\n" + "{\n" + " int a[2];\n" + " init(a - 1);\n" + " int b = a[0];\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } // alloc..