// PR c++/86981 // { dg-do compile { target c++11 } } // { dg-options "-Wpessimizing-move" } // Define std::move. namespace std { template struct remove_reference { typedef _Tp type; }; template struct remove_reference<_Tp&> { typedef _Tp type; }; template struct remove_reference<_Tp&&> { typedef _Tp type; }; template constexpr typename std::remove_reference<_Tp>::type&& move(_Tp&& __t) noexcept { return static_cast::type&&>(__t); } } struct T { }; struct U { U(T); }; template T fn1 () { T t; // Non-dependent type. return std::move (t); // { dg-warning "moving a local object in a return statement prevents copy elision" } } template Tp1 fn2 () { Tp2 t; return std::move (t); // { dg-warning "moving a local object in a return statement prevents copy elision" } } template Tp1 fn3 () { Tp2 t; return std::move (t); } int main () { fn1(); fn2(); fn3(); }