https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58589
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |NEW --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jan Kratochvil from comment #0) > #include <unordered_map> > #include <memory> > class X { > public: > int a,&b; /* the reference disables default copy constructor */ What has the copy constructor got to do with anything? std::unique_ptr<X> never tries to copy an X Reduced: template<class T> struct impl { T t; impl& operator=(const impl& i) { t = i.t; return *this; } }; template<class T> struct unordered_map { impl<T> m_impl; }; struct unique_ptr { unique_ptr& operator=(const unique_ptr&) = delete; }; struct Y { unordered_map<unique_ptr> x; }; int main() { Y a; a = a; } j.cc: In instantiation of ‘impl<T>& impl<T>::operator=(const impl<T>&) [with T = unique_ptr]’: j.cc:10:8: required from here j.cc:6:38: error: use of deleted function ‘unique_ptr& unique_ptr::operator=(const unique_ptr&)’ impl& operator=(const impl& i) { t = i.t; return *this; } ~~^~~~~ j.cc:16:15: note: declared here unique_ptr& operator=(const unique_ptr&) = delete; ^~~~~~~~ There's nothing showing the location of the "a = a" expression that requires the deleted Y::operator=(const Y&).