[Bug c++/55166] c++11: std::string and =std:move makes swapping

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 1 18:41:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55166

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-11-01 18:40:49 UTC ---
The standard says that after the move t1 will be in a valid but unspecified
state.

It does not say it will be empty.

There are performance advantages to the current behaviour because if you do
this:

std::string t0{"abc"};
std::string t1{"123"};
t0 = std::move(t1);
t1 = "xyz";

there is no allocation for the last line, because it already has memory

You keep reporting invalid bugs which are actually correct C++11 behaviour.
Please find somewhere else to learn C++, such as stackoverflow.com



More information about the Gcc-bugs mailing list