Skip to content

Commit

Permalink
Update testuninitvar.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jul 11, 2024
1 parent 77b316e commit d3e45c5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/testuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6520,6 +6520,28 @@ class TestUninitVar : public TestFixture {
" printf(\"%s\", p);\n"
"}\n");
ASSERT_EQUALS("", errout_str());

valueFlowUninit("std::string f() {\n" // #12922
" std::string a[2];\n"
" std::array<std::string, 2> b;\n"
" return a[1] + b.at(1);\n" // don't warn
"}\n"
"struct S { int i; };\n"
"struct T { int i = 0; };\n"
"int g() {\n"
" std::array<int, 2> a;\n"
" std::array<S, 2> b;\n"
" std::array<T, 2> c;\n" // don't warn
" return a.at(1) + b.at(1).i + c.at(1).i;\n"
"}\n"
"int h() {\n"
" std::array<int, 2> a;\n"
" return a[1];\n"
"}\n");
ASSERT_EQUALS("[test.cpp:12]: (error) Uninitialized variable: a\n"
"[test.cpp:12]: (error) Uninitialized variable: b\n"
"[test.cpp:16]: (error) Uninitialized variable: a\n",
errout_str());
}

void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value
Expand Down

0 comments on commit d3e45c5

Please sign in to comment.