https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107202
Bug ID: 107202 Summary: inheriting assignment operators from CRTP-base Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: h2+bugs at fsfe dot org Target Milestone: --- I stumbled over the following: ```cpp #define OPTION 0 // or 1-4 template <typename Derived> struct Base { Base() = default; Base(Base const &) = default; Base(Base &&) = default; //Base & operator=(Base const &) = delete; //Base & operator=(Base &&) = delete; #if OPTION == 1 Derived const & operator=(Derived &) { return static_cast<Derived &>(*this); } #elif OPTION == 2 Derived const & operator=(Derived &) const { return static_cast<Derived &>(*this); } #elif OPTION == 3 Derived const & operator=(Derived const &) { return static_cast<Derived &>(*this); } #elif OPTION == 4 Derived const & operator=(Derived const &) const { return static_cast<Derived &>(*this); } #endif }; struct D : Base<D> { D() = default; D(D const &) = default; D(D &&) = default; //D & operator=(D const &) = delete; //D & operator=(D &&) = delete; using Base<D>::operator=; }; int main() { D d1; D d2; d1 = d2; } ``` OPTION == 0 → no valid overload (expected!) OPTION == 1 → well-formed OPTION == 2 → ambiguous overload OPTION == 3 → no valid overload OPTION == 4 → no valid overload Clang behaves the same as GCC. MSVC never sees any valid overloads. My assumption was that implicit assignment operators are inhibited in all cases (this is also shown by OPTION == 0), but that any of the inherited operators should be valid. Should the implicit deletion of the assignment-operator in D prevent inheriting the user-defined assignment operators from Base, why does this affect some of them and not others?