[v3] Fix move assignment operators vs self assignment

Bo Persson bop@gmb.dk
Sat Jan 9 10:13:00 GMT 2010


Paolo Carlini wrote:

> Hi,
>
> a serious oversight, sorry. Tested x86_64-linux, committed to
> mainline.
>
> Paolo.
>
> /////////////////

I believe this might not be a serious oversight at all, but rather an 
early implementation of the resolution to Library Issue #1204.

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#1204

where it says:

"Additionally this clarifies that move assignment operators need not 
perform the traditional if (this != &rhs) test commonly found (and 
needed) in copy assignment operators."


The only way to get a move self assignment is to use x = std::move(x). 
If you actually do that, the library might not be required to save 
you.



Bo Persson



More information about the Gcc-patches mailing list