https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43127
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- First note C++17+ changed the rules so using C++17 allows this to compile, guaranteed copy elision (https://en.cppreference.com/w/cpp/language/copy_elision) so no copy is required or even tried. Second, the code is in fact invalid C++98/03/11/14 . To make it valid C++11/14, you can use the rvalue reference instead for the constructor: auto_ptr(auto_ptr<type>&& source) For valid C++98, you could add a constructor which takes a const reference which allows binding a temporary to it: auto_ptr(const auto_ptr<type>& source)