Added a regression test for FP #10681 uninitvar. (#5168)

Test case is from: https://trac.cppcheck.net/ticket/10681#comment:10
This commit is contained in:
orbitcowboy 2023-06-17 15:45:28 +02:00 committed by GitHub
parent d6e3182441
commit fd3befe60a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -6875,6 +6875,23 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
valueFlowUninit("struct S {\n"
" int t[1];\n"
" int u;\n"
"};\n"
"\n"
"int f(const S* ps) {\n"
" return ps->t[0];\n"
"}\n"
"\n"
"int main(void)\n"
"{\n"
" S s;\n"
" s.t[0] = 1;\n"
" f(&s);\n"
"}");
ASSERT_EQUALS("", errout.str());
valueFlowUninit("struct X {\n"
" int a, b;\n"
"};\n"