From 89e60af516944eed44614adb7e3f0b778c1e6499 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Sat, 8 Jan 2022 17:45:45 +0100 Subject: [PATCH] Ticket #1586 - Added regression test --- test/testbufferoverrun.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index dc75674bf..6bea58c5a 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -189,7 +189,7 @@ private: TEST_CASE(array_index_negative3); TEST_CASE(array_index_negative4); TEST_CASE(array_index_for_decr); - TEST_CASE(array_index_varnames); // FP: struct member. #1576 + TEST_CASE(array_index_varnames); // FP: struct member #1576, FN: #1586 TEST_CASE(array_index_for_continue); // for,continue TEST_CASE(array_index_for); // FN: for,if TEST_CASE(array_index_for_neq); // #2211: Using != in condition @@ -2098,6 +2098,20 @@ private: " a.data[3] = 0;\n" "}"); ASSERT_EQUALS("", errout.str()); + + // #1586 + check("struct A {\n" + " char data[4];\n" + " struct B { char data[3]; };\n" + " B b;\n" + "};\n" + "\n" + "void f()\n" + "{\n" + " A a;\n" + " a.data[4] = 0;\n" + "}"); + ASSERT_EQUALS("[test.cpp:10]: (error) Array 'a.data[4]' accessed at index 4, which is out of bounds.\n", errout.str()); } void array_index_for_andand_oror() { // #3907 - using && or ||