#7682 Added regression test

This commit is contained in:
orbitcowboy 2021-03-26 10:54:08 +01:00
parent 6fd916a90f
commit 185a5e1ee6
1 changed files with 12 additions and 0 deletions

View File

@ -132,6 +132,7 @@ private:
TEST_CASE(array_index_49); // #8653
TEST_CASE(array_index_50);
TEST_CASE(array_index_51); // #3763
TEST_CASE(array_index_52); // #7682
TEST_CASE(array_index_multidim);
TEST_CASE(array_index_switch_in_for);
TEST_CASE(array_index_for_in_for); // FP: #2634
@ -1534,6 +1535,17 @@ private:
ASSERT_EQUALS("[test.cpp:3]: (error) Array 'd[1]' accessed at index 1, which is out of bounds.\n", errout.str());
}
void array_index_52() {
check("char f(void)\n"
"{\n"
" char buf[10];\n"
" for(int i = 0, j= 11; i < j; ++i)\n"
" buf[i] = 0;\n"
" return buf[0];\n"
"}");
ASSERT_EQUALS("[test.cpp:5]: (error) Array 'buf[10]' accessed at index 10, which is out of bounds.\n", errout.str());
}
void array_index_multidim() {
check("void f()\n"
"{\n"