From 6fd916a90fcfafc6fd56877e40405385540208e7 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Fri, 26 Mar 2021 10:01:44 +0100 Subject: [PATCH] #3763 Added regression test --- test/testbufferoverrun.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 90e15bd5f..5ffe6711b 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -131,6 +131,7 @@ private: TEST_CASE(array_index_48); // #9478 TEST_CASE(array_index_49); // #8653 TEST_CASE(array_index_50); + TEST_CASE(array_index_51); // #3763 TEST_CASE(array_index_multidim); TEST_CASE(array_index_switch_in_for); TEST_CASE(array_index_for_in_for); // FP: #2634 @@ -1525,6 +1526,14 @@ private: ASSERT_EQUALS("", errout.str()); } + void array_index_51() { + check("void f(void){\n" + " int k=0, dd, d[1U] = {1};\n" + " for (dd=d[k]; k<10; dd=d[++k]){;}\n" + "}"); + ASSERT_EQUALS("[test.cpp:3]: (error) Array 'd[1]' accessed at index 1, which is out of bounds.\n", errout.str()); + } + void array_index_multidim() { check("void f()\n" "{\n"