http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52901
Marc Glisse <marc.glisse at normalesup dot org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |marc.glisse at normalesup | |dot org --- Comment #3 from Marc Glisse <marc.glisse at normalesup dot org> 2012-04-08 15:32:45 UTC --- (In reply to comment #2) > > X&& f() { > > X x; > > return std::move(x); > > } > > This function is unsafe, it returns a reference to a local variable. You > probably meant it to return X not X&& > > It is effectively the same as: > > X& f() { > X x; > return x; > } > > (except G++ warns about that, because it's simpler) Maybe this could be taken as a RFE for a warning with std::move? Many people learning C++11 are bound to try similar things. g++ warns for return X(); return static_cast<X&&>(x); but not return std::move(x); I expect the case of std::move to be important enough that if doing a generic warning is too hard, special-casing std::move could be worth the trouble (assuming it is easier).