Skip to content

Commit 2a86e5f

Browse files
Update testother.cpp
1 parent fe83217 commit 2a86e5f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎test/testother.cpp‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11461,7 +11461,31 @@ class TestOther : public TestFixture {
1146111461
" i = std::distance(v.begin(), std::find_if(v.begin(), v.end(), [=](int j) { return i == j; }));\n"
1146211462
" return i;\n"
1146311463
"}\n");
11464+
1146411465
ASSERT_EQUALS("", errout_str());
11466+
check("int g();\n" // #15023
11467+
"int f1() {\n"
11468+
" int i{ g() };\n"
11469+
" i = 0;\n"
11470+
" return i;\n"
11471+
"}\n"
11472+
"int f2() {\n"
11473+
" int i(g());\n"
11474+
" i = 0;\n"
11475+
" return i;\n"
11476+
"}\n"
11477+
"int f3() {\n"
11478+
" int i{ 1 };\n"
11479+
" i = 0;\n"
11480+
" return i;\n"
11481+
"}\n");
11482+
ASSERT_EQUALS("[test.cpp:4:7]: style: Redundant initialization for 'i'. The initialized value is overwritten before it is read. [redundantInitialization]\n"
11483+
"[test.cpp:3:10]: note: i is initialized\n"
11484+
"[test.cpp:4:7]: note: i is overwritten\n"
11485+
"[test.cpp:9:7]: style: Redundant initialization for 'i'. The initialized value is overwritten before it is read. [redundantInitialization]\n"
11486+
"[test.cpp:8:10]: note: i is initialized\n"
11487+
"[test.cpp:9:7]: note: i is overwritten\n",
11488+
errout_str());
1146511489
}
1146611490

1146711491
// cppcheck-suppress unusedPrivateFunction

0 commit comments

Comments
 (0)