Skip to content

Commit bcd87b0

Browse files
Update testother.cpp
1 parent 4d8eab3 commit bcd87b0

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/testother.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10613,6 +10613,21 @@ class TestOther : public TestFixture {
1061310613
ASSERT_EQUALS(
1061410614
"[test.cpp:2:10]: (style) Variable 'a' can be declared as pointer to const [constVariablePointer]\n",
1061510615
errout_str());
10616+
10617+
check("std::string f() {\n" // #14534
10618+
" std::string s = \"abc\";\n"
10619+
" s = \"def\";\n"
10620+
" return s;\n"
10621+
"}\n"
10622+
"const char* g() {\n"
10623+
" const char* p = \"abc\";\n"
10624+
" p = \"def\";\n"
10625+
" return p;\n"
10626+
"}");
10627+
ASSERT_EQUALS(
10628+
"[test.cpp:2:19] -> [test.cpp:3:7]: (style) Redundant initialization for 's'. The initialized value is overwritten before it is read. [redundantInitialization]\n"
10629+
"[test.cpp:7:19] -> [test.cpp:8:7]: (style) Redundant initialization for 'p'. The initialized value is overwritten before it is read. [redundantInitialization]\n",
10630+
errout_str());
1061610631
}
1061710632

1061810633
void redundantVarAssignment_struct() {

0 commit comments

Comments
 (0)