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

            Bug ID: 102357
           Summary: The type specified by explicitly defaulted special
                    member function that is different with it should have
                    had is well-formed
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xmh970252187 at gmail dot com
  Target Milestone: ---

struct C{
    C() = default;
    C(C const volatile&) = default;
};
int main() {
}

GCC reports an error as a diagnosis while Clang merely reports a warning.
According to [dcl.fct.def#default-2]

> The type T1 of an explicitly defaulted special member function F is allowed 
> to differ from the type T2 it would have had if it were implicitly declared, 
> as follows: 

>> [...]

> if T1 differs from T2
>> if F is an assignment operator, and the return type of T2 differs from the 
>> return type of T2 or T1's parameter type is not a reference, the program is 
>> ill-formed;

>> **otherwise, if F is explicitly defaulted on its first declaration, it is 
>> defined as deleted;** 
>>otherwise, the program is ill-formed.


As per the following
> otherwise, if F is explicitly defaulted on its first declaration, it is 
> defined as deleted;

There are no requirements to let implementations report an diagnosis, let alone
make the program ill-formed. A warning is sufficient here.

Reply via email to