You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0f2d722
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: test/testclass.cpp
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,7 @@ class TestClass : public TestFixture {
84
84
TEST_CASE(operatorEqToSelf7);
85
85
TEST_CASE(operatorEqToSelf8); // ticket #2179
86
86
TEST_CASE(operatorEqToSelf9); // ticket #2592
87
+
TEST_CASE(operatorEqToSelf10); // ticket #15156
87
88
88
89
TEST_CASE(memsetOnStruct);
89
90
TEST_CASE(memsetVector);
@@ -2674,6 +2675,23 @@ class TestClass : public TestFixture {
2674
2675
ASSERT_EQUALS("", errout_str());
2675
2676
}
2676
2677
2678
+
voidoperatorEqToSelf10() {
2679
+
checkOpertorEqToSelf(
2680
+
"class Foo\n"
2681
+
"{\n"
2682
+
" int32_t * p;\n"
2683
+
"public:\n"
2684
+
" Foo& operator=( Foo && o ) noexcept\n"
2685
+
" {\n"
2686
+
" delete p;\n"
2687
+
" p = o.p;\n"
2688
+
" o.p = nullptr;\n"
2689
+
" return *this;\n"
2690
+
" }\n"
2691
+
"};\n");
2692
+
ASSERT_EQUALS("[test.cpp:5:10]: (warning) 'operator=' should check for assignment to self to avoid problems with dynamic memory. [operatorEqToSelf]\n", errout_str());
0 commit comments