diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 65dba6d49..b47f8c251 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -3585,6 +3585,19 @@ private: " f(\"bbb\", 3);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void f(int i, const char* a) {\n" // #11140 + " (void)a[i];\n" + "}\n" + "void g() {\n" + " for (int i = 0; \"01234\"[i]; ++i)\n" + " f(i, \"56789\");\n" + "}\n" + "void h() {\n" + " for (int i = 0; \"012\"[i]; ++i)\n" + " f(i, \"345\");\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } diff --git a/test/testother.cpp b/test/testother.cpp index 32c86d81b..3739a8ea6 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -5964,6 +5964,15 @@ private: " }\n" "}"); ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:5]: (style) The comparison 'Diag == 0' is always true.\n", errout.str()); + + // #9744 + check("void f(const std::vector& ints) {\n" + " int i = 0;\n" + " for (int p = 0; i < ints.size(); ++i) {\n" + " if (p == 0) {}\n" + " }\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) The comparison 'p == 0' is always true.\n", errout.str()); } void duplicateExpression8() {