This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/44158] [C++0x] wrong overload resolution for copy-initialization from an rvalue
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 May 2010 17:07:08 -0000
- Subject: [Bug c++/44158] [C++0x] wrong overload resolution for copy-initialization from an rvalue
- References: <bug-44158-19147@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from redi at gcc dot gnu dot org 2010-05-16 17:07 -------
The rules say that for copy-initialization where the source type (X&&) is not
the same as the destination type (X) a temporary is created. That temporary is
copy-constructed from x, then y is move-constructed from the temporary.
To avoid the temporary use direct-initialization;
Y y( static_cast<X&&>(x) );
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44158