On Sat, Nov 27, 2010 at 4:13 PM, Roman Kononov <ro...@binarylife.net> wrote: > Hello, > > Is it a bug or am I missing something? > > $ cat test.cpp > #include <memory> > > struct X { > X()=default; > X(X&&)=default; > }; > > X test() { > X const a={}; > return std::move(a); > } > > $ g++ -c -std=c++0x test.cpp > test.cpp: In function 'X test()': > test.cpp:10:22: error: no matching function for call to > 'X::X(std::remove_reference<const X&>::type)' > test.cpp:5:4: note: candidates are: constexpr X::X(X&&) > test.cpp:4:4: note: constexpr X::X() > > This is v4.6. v4.5 is happy here.
4.6 appears to be right -- you cannot bind an X&& to a const X (which is good, as otherwise you could change the const X). 4.5 (partially?) implemented an older set of rules about rvalue references etc. 4.6 is much closer to the current draft standard (though those rules have been changing very recently in some details). -- James