From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 933763858D37; Mon, 10 Oct 2022 19:32:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 933763858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665430320; bh=K9aHpQQL5mxRJQY5/7vWgIf1pH+9IM91v0fbO+SLUv0=; h=From:To:Subject:Date:From; b=FneHycQ9COGjU2mvvgDtXmFQCYyQl1BbjghgM0po8cA1sCqH9TchopsmKxDNmmXTK FkLngk2tFbiz0rWOm52o3DS59mmeY4D0BgF11m/44kX1b5MYWngt+znKGM361eh2hX LqYQd5ijA2q7LeydrueXf0mmIoxK3tgdMrfpLX6g= From: "h2+bugs at fsfe dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107202] New: inheriting assignment operators from CRTP-base Date: Mon, 10 Oct 2022 19:32:00 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: h2+bugs at fsfe dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107202 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 struct Base { Base() =3D default; Base(Base const &) =3D default; Base(Base &&) =3D default; //Base & operator=3D(Base const &) =3D delete; //Base & operator=3D(Base &&) =3D delete; #if OPTION =3D=3D 1 Derived const & operator=3D(Derived &) { return static_cast(*this); } #elif OPTION =3D=3D 2 Derived const & operator=3D(Derived &) const { return static_cast(*this); } #elif OPTION =3D=3D 3 Derived const & operator=3D(Derived const &) { return static_cast(*this); } #elif OPTION =3D=3D 4 Derived const & operator=3D(Derived const &) const { return static_cast(*this); } #endif }; struct D : Base { D() =3D default; D(D const &) =3D default; D(D &&) =3D default; //D & operator=3D(D const &) =3D delete; //D & operator=3D(D &&) =3D delete; using Base::operator=3D; }; int main() { D d1; D d2; d1 =3D d2; } ``` OPTION =3D=3D 0 =E2=86=92 no valid overload (expected!) OPTION =3D=3D 1 =E2=86=92 well-formed OPTION =3D=3D 2 =E2=86=92 ambiguous overload OPTION =3D=3D 3 =E2=86=92 no valid overload OPTION =3D=3D 4 =E2=86=92 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 c= ases (this is also shown by OPTION =3D=3D 0), but that any of the inherited oper= ators 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?=