From 97f84a368d5088540164ee9adcd2f1d4f43687bb Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Sun, 5 Dec 2021 17:44:57 +0100 Subject: [PATCH] Ticket #8648: Added regression test. --- test/teststl.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/teststl.cpp b/test/teststl.cpp index 79a57331a..c3f922029 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -215,6 +215,24 @@ private: void outOfBounds() { setMultiline(); + checkNormal("bool f(const int a, const int b)\n" // #8648 + "{\n" + " std::cout << a << b;\n" + " return true;\n" + "}\n" + "void f(const std::vector &v)\n" + "{\n" + " if(v.size() >=2 &&\n" + " bar(v[2], v[3]) )\n" // v[3] is accessed + " {;}\n" + "}\n"); + ASSERT_EQUALS("test.cpp:9:warning:Either the condition 'v.size()>=2' is redundant or v size can be 2. Expression 'v[2]' cause access out of bounds.\n" + "test.cpp:8:note:condition 'v.size()>=2'\n" + "test.cpp:9:note:Access out of bounds\n" + "test.cpp:9:warning:Either the condition 'v.size()>=2' is redundant or v size can be 2. Expression 'v[3]' cause access out of bounds.\n" + "test.cpp:8:note:condition 'v.size()>=2'\n" + "test.cpp:9:note:Access out of bounds\n", errout.str()); + checkNormal("void f() {\n" " std::string s;\n" " s[10] = 1;\n"