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

            Bug ID: 116227
           Summary: Implicit copy assignment operator is defined in the
                    presence of user copy assignment operator
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

In the following C++23 program struct A has user-defined copy assignment
operator with explicit object parameter of type (const A &), and the compiler
must not declare any copy or move assignment operator implicitly.
```
struct A {
    int operator =(this const A &, const A&) { return 1; }
};

int i = A{} = A{};
```
The program is accepted by Clang, but in GCC an implicitly-defined copy
assignment operator is invoked that results in compilation error (cannot
convert A to int). Online demo: https://gcc.godbolt.org/z/Wor93bfqM

Original discussion: https://stackoverflow.com/q/78829719/7325599

Reply via email to