-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rule-of-two-soft: Honour explicitly defaulted copy-ctor/operator
The user signaled he knows what he's doing and there's even valid use cases BUG: 443343
- Loading branch information
Sergio Martins
committed
Oct 26, 2021
1 parent
2ea8718
commit 854f340
Showing
4 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
struct Test | ||
{ | ||
Test() {} | ||
~Test() { } | ||
|
||
Test(const Test &) {} | ||
Test& operator=(const Test&) = default; | ||
}; | ||
|
||
void test() | ||
{ | ||
Test t; | ||
Test t2; | ||
t = t2; // OK, the developer explicitly says he wants the default copy-assign op | ||
} | ||
|
||
struct Test2 | ||
{ | ||
Test2() {} | ||
~Test2() { } | ||
|
||
Test2(const Test2 &) {} | ||
}; | ||
|
||
void test2() | ||
{ | ||
Test2 t; | ||
Test2 t2; | ||
t = t2; // Warn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rule-of-two-soft/bug443343.cpp:29:5: warning: Using assign operator but class Test2 has copy-ctor but no assign operator [-Wclazy-rule-of-two-soft] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ | |
}, | ||
{ | ||
"filename" : "bug375537.cpp" | ||
}, | ||
{ | ||
"filename" : "bug443343.cpp" | ||
} | ||
] | ||
} |