forked from dashpay/dash
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #2089: [Refactor] Fix some -Wdeprecated-copy warnings
ae41ebe Remove redundant explicitly defined copy ctors (Dan Raviv) 454aa37 Trivial: explicit (default) copy-constructor for CTransaction (random-zebra) 2af2306 Cleanup: Remove redundant copy-constructor for CSignedMessage (random-zebra) e28259d Masternode: proper copy-assignment for CMasternode/CmasternodePing (random-zebra) Pull request description: Fix the `-Wdeprecated-copy` warnings listed in #2076 **Background** While perfectly valid in C++98, implicit generation of the copy constructor is declared as deprecated in C++11, when there is already a user-defined copy assignment operator, or vice-versa. The rationale behind this is the "rule of three" (https://en.cppreference.com/w/cpp/language/rule_of_three) > If a class requires a user-defined destructor, a user-defined copy constructor, or a user-defined copy assignment operator, it almost certainly requires all three. **Issue - Fix** We have several places that define redundant copy assignment operators (and then use the implicit copy constructor), or that do need non-default ctors/dtors but don't define copy assignment. (See also bitcoin#11161, which is also cherry-picked here) Specifically: - `CSignedMessage`/`CMasternodePing`/`CMasternode` use a weird copy-assignment that *swaps* with the argument (which, of course, cannot be "const" then). Here we remove all ::swap implementations, and provide actual copy assignment operators. - `CTransaction` has an explicit copy-assignment operator, but uses the implicit copy-ctor in `CMerkleTx` constructor. - `CFeeRate` and `CTxMemPoolEntry` have explicitly defined copy ctor, which can (and should, for the rule-of-three) be replaced by the default one (bitcoin#11161). **Note** Reason why these warnings pop up just now. Since Clang 10.0 and GCC 9.3, `-Wextra` enables `-Wdeprecated-copy` by default, and that is very spammy, especially when compiling with the QT GUI (bitcoin#15822 / bitcoin#18419). It is so spammy (also with `boost-1.72.0`) that Bitcoin decided to temporarily suppress this warning (bitcoin#18738) until QT fixes it upstream, and boost is definitely removed in 0.22 (bitcoin#18967) ACKs for top commit: furszy: utACK ae41ebe Tree-SHA512: 1f59f9f7426abbf4b7d4bb0d1ac50491eb52f776e2a018de3acc8ab381af3b69db6b9a5b60c04b48f0d495e560eaa1e3d19be03d133f230daca66ba66e766289
- Loading branch information
Showing
7 changed files
with
16 additions
and
67 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
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
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
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