http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49447
Summary: operator= (and compound assignment ops) does not perfectly forward Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: lucdan...@free.fr Created attachment 24549 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24549 Minimal example An operator= (or compound assignment operator) that perfectly forwards its argument, like so: template<typename T> T&& operator=(T&& t) { return std::forward<T>(t); } does not behave exactly like a member will: template<typename T> T&& member(T&& t) { return std::forward<T>(t); } In particular, for some types (integral types it seems), when passed an lvalue reference to const, operator= returns an rvalue reference to const, e.g. long const& becomes long const&&. This does not happen for e.g. pointer types, class types or float or double; or when the function is instead declared as e.g. operator+ (but not operator+=) or as a regular member. This is using: gcc version 4.7.0 20110531 (experimental) [trunk revision 174470] (Debian 20110531-1) Attached is an example which fails to compile from trying to take the address of the result of operator= and from triggering a static_assert.