Skip to content

Commit db68cfa

Browse files
committed
Add a TODO test for a for loop flag set at the last valid index
1 parent bec10bb commit db68cfa

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎test/testbufferoverrun.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,6 +2721,16 @@ class TestBufferOverrun : public TestFixture {
27212721
" return n;\n"
27222722
"}\n");
27232723
ASSERT_EQUALS("", errout_str());
2724+
2725+
check("void f() {\n"
2726+
" int a[10];\n"
2727+
" for (int i = 0, done = 0; done == 0; i++) {\n"
2728+
" a[i] = 0;\n"
2729+
" if (i == 9)\n"
2730+
" done = 1;\n"
2731+
" }\n"
2732+
"}\n");
2733+
TODO_ASSERT_EQUALS("", "[test.cpp:5:15] -> [test.cpp:4:10]: (warning) Either the condition 'i==9' is redundant or the array 'a[10]' is accessed at index 10, which is out of bounds. [arrayIndexOutOfBoundsCond]\n", errout_str());
27242734
}
27252735

27262736
void array_index_for_neq() {

0 commit comments

Comments
 (0)