#3838 added more testcases.
This commit is contained in:
parent
19c430530f
commit
c8798b2207
|
@ -1489,14 +1489,31 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// avoid FP (example taken from #3838)
|
||||
// avoid FPs (modified examples taken from #3838)
|
||||
check("struct AB { int a[10]; int b[10]; };\n"
|
||||
"int main() {\n"
|
||||
" struct AB ab;\n"
|
||||
" int * p = &ab[0].a[10]; \n"
|
||||
" int * p = &ab.a[10]; \n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct AB { int a[10]; int b[10]; };\n"
|
||||
"int main() {\n"
|
||||
" struct AB ab[1];\n"
|
||||
" int * p = &ab[0].a[10]; \n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
|
||||
check("struct AB { int a[10]; int b[10]; };\n"
|
||||
"int main() {\n"
|
||||
" struct AB ab[1];\n"
|
||||
" int * p = &ab[10].a[0]; \n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Array 'ab[1]' accessed at index 10, which is out of bounds.\n", errout.str());
|
||||
}
|
||||
|
||||
void array_index_44() { // #3979 (false positive)
|
||||
|
|
Loading…
Reference in New Issue