We started scanning cross-platform code base with Coverity on Windows. On Windows we picked up five Missing move assignment operator (MISSING_MOVE_ASSIGNMENT)
findings. The findings are not present on Unix, Linux or OS X.
We are a C++ library compatible with C++03 - C++17. To date, we have left move assignments alone because Jonathan Wakely advised us to do so (from How to determine when a C++11 move is synthesized? on the GCC mailing list):
So you should not need to care [about providing a move]. If moving might not be safe, it won't happen. If moving would be safe then it might happen, but in those cases you are probably better off letting the compiler generate a correct move rather than interfere.
I'd like to know what criteria Coverity uses for the finding. How does Coverity determine there's an opportunity for us to improve the compiler generated one?
(I'm not challenging the finding. I'm trying to better understand it, understand why the Scan Service thinks we can do a better job, and understand where the opportunity lay. And "better job" may only apply to Windows).
Here's one of the findings. The others are available on the Coverity Scan site.
CID undefined (#1 of 1): Missing move assignment operator (MISSING_MOVE_ASSIGNMENT)
missing_move_assignment: Class CryptoPP::EC2NPoint may benefit from adding a move assignment
operator. See other events which show the copy assignment operator being applied to rvalue(s),
where a move assignment may be faster.
22 struct CRYPTOPP_DLL EC2NPoint
23 {
24 virtual ~EC2NPoint() {}
25
26 EC2NPoint() : identity(true) {}
27 EC2NPoint(const PolynomialMod2 &x, const PolynomialMod2 &y)
28 : identity(false), x(x), y(y) {}
30
31 bool operator==(const EC2NPoint &t) const
31 {return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
32 bool operator< (const EC2NPoint &t) const
33 {return identity ? !t.identity : (!t.identity && (x<t.x || (x==t.x && y<t.y)));}
34
35 bool identity;
36 PolynomialMod2 x, y;
37 };