https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80858

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The problem isn't limited to implicitly-declared special members. If we adjust
comment 4 so that B::operator=(const B&) is user-declared but defined as
defaulted:

 struct Empty {
};

template<class T>
struct A
{
        A &operator=(const A&) 
        {
                T t(3);
                return *this;
        }       
};

class B
{       
        A<Empty> a;

public:
        B& operator=(const B&) = default;
};

int main(void)
{
        B b1, b2;
        b1 = b2;
}


Then we get almost the same error. The only difference is that the "required
from here" line points to the defaulted operator= instead of to the class head,
i.e. we get
head.cc:19:12:   required from here
instead of:
head.cc:14:7:   required from here

Which is a little better, but it's still easy to miss that line among the other
diagnostics.

This would still be greatly improved by "required from the implicitly-defined
copy assignment operator" instead of "required from here".

tl;dr we should name the special member that we're generating a defaulted
definition for, instead of just saying "here".

That's what EDG does, see comment 5:

          detected during:
            instantiation of "A<T> &A<T>::operator=(const A<T> &) [with
                      T=Empty]" at line 22
            implicit generation of "B &B::operator=(const B &)" at line 22

Reply via email to