Add test for #7686 (#3878)

* Add test for #7686

* Format
This commit is contained in:
chrchr-github 2022-03-07 15:32:14 +01:00 committed by GitHub
parent 461d797094
commit 25360d5e4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -2237,6 +2237,16 @@ private:
" }\n"
"}");
ASSERT_EQUALS("[test.cpp:4]: (error) Array 'a[10]' accessed at index 10, which is out of bounds.\n", errout.str());
// #7686
check("char f() {\n"
" char buf[10];\n"
" const bool a = true, b = true;\n"
" for (int i = 0; i < (a && b ? 11 : 10); ++i)\n"
" buf[i] = 0;\n"
" return buf[0];\n"
"}\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_for_neq() {