diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index ff6f14000..3ef0133d0 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -9218,6 +9218,7 @@ struct ValueFlowPassRunner { return run(pass); })) return true; + --n; } if (state.settings->debugwarnings) { if (n == 0 && values != getTotalValues()) { diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index c4b7542fe..02d72a0c4 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -7189,6 +7189,23 @@ private: " }\n" "}\n"; valueOfTok(code, "i"); + + code = "void f() {\n" // #11701 + " std::vector v(500);\n" + " for (int i = 0; i < 500; i++) {\n" + " if (i < 122)\n" + " v[i] = 255;\n" + " else if (i == 122)\n" + " v[i] = 220;\n" + " else if (i < 386)\n" + " v[i] = 196;\n" + " else if (i == 386)\n" + " v[i] = 118;\n" + " else\n" + " v[i] = 0;\n" + " }\n" + "}\n"; + valueOfTok(code, "i"); } void valueFlowCrashConstructorInitialization() { // #9577