In a recent discussion on comp.std.c++ "rvalue references returned from a function", as pointed by Niels Dekker and Micael Dark, a defect report:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#391 was accepted into C++0x WP. This has a significant impact on GCC. The current behavior also creates a problem with the following: struct R { R(const R &); }; R && func(); int main() { R const & r1 = func(); R && r2 = func(); } Both r1 and r2 will be bound to a temporary which will be created by copying (or if available - moving) the returned rvalue. This is invalid according to the mentioned changes. -- Summary: Require direct binding of short-lived references to rvalues Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dragan at plusplus dot co dot yu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40682