Skip to content

Commit e23a967

Browse files
committed
#4750 Added a regression test
1 parent 185a5e1 commit e23a967

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/testbufferoverrun.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class TestBufferOverrun : public TestFixture {
133133
TEST_CASE(array_index_50);
134134
TEST_CASE(array_index_51); // #3763
135135
TEST_CASE(array_index_52); // #7682
136+
TEST_CASE(array_index_53); // #4750
136137
TEST_CASE(array_index_multidim);
137138
TEST_CASE(array_index_switch_in_for);
138139
TEST_CASE(array_index_for_in_for); // FP: #2634
@@ -1546,6 +1547,18 @@ class TestBufferOverrun : public TestFixture {
15461547
ASSERT_EQUALS("[test.cpp:5]: (error) Array 'buf[10]' accessed at index 10, which is out of bounds.\n", errout.str());
15471548
}
15481549

1550+
void array_index_53() {
1551+
check("double M[3][1];\n"
1552+
" \n"
1553+
"void matrix()\n"
1554+
"{\n"
1555+
" for (int i=0; i < 3; i++)\n"
1556+
" for (int j = 0; j < 3; j++)\n"
1557+
" M[i][j]=0.0;\n"
1558+
"}");
1559+
ASSERT_EQUALS("[test.cpp:7]: (error) Array 'M[3][1]' accessed at index M[*][2], which is out of bounds.\n", errout.str());
1560+
}
1561+
15491562
void array_index_multidim() {
15501563
check("void f()\n"
15511564
"{\n"

0 commit comments

Comments
 (0)