#include <unordered_map> #include <memory> class X { public: int a,&b; /* the reference disables default copy constructor */ X():b(a) {} }; class Y { public: std::unordered_map<int,std::unique_ptr<X>> x; /* this hides the error line */ } a,b; int main() { a=b; } $ g++ -o test6 test6.C -Wall -std=gnu++11 2>&1|grep test6 Actual: from test6.C:1: from test6.C:1: from test6.C:2: Expected: from test6.C:5: (or at ltest test6.C:3) There are many error lines also mentioning 'X' (although neither 'a' or 'b') but none of them gives any line number where the problem comes from in test6.C. Editors/IDE (error line parsers) then cannot show where the error comes from. Also none of the errors is the one making the cause clear which one gets by using plain 'X x;' (instead of using 'X' in unordered_map): test6.C:3:7: error: non-static reference member ‘int& X::b’, can’t use default assignment operator BTW clang has the same diagnostics problem.
A minimized testcase would be appreciated: https://gcc.gnu.org/bugs/minimize.html
Waiting for a minimized testcase.
(In reply to Manuel López-Ibáñez from comment #2) > Waiting for a minimized testcase. Changing status to actually be WAITING then.
(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&).
(In reply to Jonathan Wakely from comment #4) > There's nothing showing the location of the "a = a" expression that requires > the deleted Y::operator=(const Y&). IMHO, the problem is the instantiation trace: > j.cc:10:8: required from here does not show any useful location. It should show the location of "a = a"