added test case for #1193 (false negative: array out of bounds in loop when there is calculation)
This commit is contained in:
parent
e286896d75
commit
79223b71d5
|
@ -95,6 +95,7 @@ private:
|
||||||
TEST_CASE(array_index_23);
|
TEST_CASE(array_index_23);
|
||||||
TEST_CASE(array_index_multidim);
|
TEST_CASE(array_index_multidim);
|
||||||
TEST_CASE(array_index_switch_in_for);
|
TEST_CASE(array_index_switch_in_for);
|
||||||
|
TEST_CASE(array_index_calculation);
|
||||||
|
|
||||||
TEST_CASE(buffer_overrun_1);
|
TEST_CASE(buffer_overrun_1);
|
||||||
TEST_CASE(buffer_overrun_2);
|
TEST_CASE(buffer_overrun_2);
|
||||||
|
@ -819,9 +820,25 @@ private:
|
||||||
" };\n"
|
" };\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
TODO_ASSERT_EQUALS("[test.cpp:12]: (error) Array index out of bounds\n", errout.str());
|
TODO_ASSERT_EQUALS("[test.cpp:12]: (error) Array index out of bounds\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void array_index_calculation()
|
||||||
|
{
|
||||||
|
// #1193 - false negative: array out of bounds in loop when there is calculation
|
||||||
|
check("void f()\n"
|
||||||
|
"{\n"
|
||||||
|
" int ar[5];\n"
|
||||||
|
" for (int i = 10; i < 20; ++i)\n"
|
||||||
|
" {\n"
|
||||||
|
" ar[(i - 10) / 2] = 0;\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
TODO_ASSERT_EQUALS("[test.cpp:6]: (error) Array index out of bounds\n", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void buffer_overrun_1()
|
void buffer_overrun_1()
|
||||||
{
|
{
|
||||||
check("void f()\n"
|
check("void f()\n"
|
||||||
|
|
Loading…
Reference in New Issue