tests/rule-of-two-soft/bug443343.cpp
raw| 1 | struct Test |
| 2 | { |
| 3 | Test() {} |
| 4 | ~Test() { } |
| 5 | |
| 6 | Test(const Test &) {} |
| 7 | Test& operator=(const Test&) = default; |
| 8 | }; |
| 9 | |
| 10 | void test() |
| 11 | { |
| 12 | Test t; |
| 13 | Test t2; |
| 14 | t = t2; // OK, the developer explicitly says he wants the default copy-assign op |
| 15 | } |
| 16 | |
| 17 | struct Test2 |
| 18 | { |
| 19 | Test2() {} |
| 20 | ~Test2() { } |
| 21 | |
| 22 | Test2(const Test2 &) {} |
| 23 | }; |
| 24 | |
| 25 | void test2() |
| 26 | { |
| 27 | Test2 t; |
| 28 | Test2 t2; |
| 29 | t = t2; // Warn |
| 30 | } |