[SERVER-70706] Coverity analysis defect 133999: Move constructor without move assignment Created: 19/Oct/22 Updated: 29/Oct/23 Resolved: 02/Nov/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | None |
| Fix Version/s: | 6.2.0-rc0 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Coverity Collector User | Assignee: | Svilen Mihaylov (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | coverity, neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Backwards Compatibility: | Fully Compatible |
| Sprint: | QO 2022-11-14 |
| Participants: |
| Description |
|
Copy without assign This class has a user-defined copy constructor but no user-defined assignment operator. If the copy constructor is necessary to manage owned resources then a corresponding assignment operator is usually required. If an object of this type is assigned memory leaks and/or use-after-free errors may occur. Note that a compiler-generated assignment operator will perform only a bit-wise copy for any fields that do not have their own assignment operators defined. Class has user-written copy constructor but no user-written assignment operator |
| Comments |
| Comment by Githook User [ 02/Nov/22 ] |
|
Author: {'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'svilen-mihaylov'}Message: |
| Comment by Kyle Suarez [ 19/Oct/22 ] |
|
The complaint about the copy constructor is a false positive, because explicitly deleting the copy constructor will cause the copy assignment operator to also be deleted. However, the move constructor is marked as = default, so I think we do need to mark the move assignment operator as also = default as it won't be generated by default? |