[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: PNG File Screen Shot 2022-10-19 at 4.13.59 PM.png    
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
/src/mongo/db/query/optimizer/cascades/memo_defs.h:56: COPY_WITHOUT_ASSIGN 133999 Class "mongo::optimizer::cascades::OrderPreservingABTSet" has a user-written copy constructor "mongo::optimizer::cascades::OrderPreservingABTSet::OrderPreservingABTSet(mongo::optimizer::cascades::OrderPreservingABTSet const &) =delete" but no corresponding user-written assignment operator.
/src/mongo/db/query/optimizer/cascades/memo_defs.h:59: COPY_WITHOUT_ASSIGN 133999 User-written copy constructor.



 Comments   
Comment by Githook User [ 02/Nov/22 ]

Author:

{'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'svilen-mihaylov'}

Message: SERVER-70706 Move constructor without move assignment
Branch: master
https://github.com/mongodb/mongo/commit/2a6386e6d6c1f847248e468a6407907484f58fb6

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?

Generated at Thu Feb 08 06:16:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.