public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "h2+bugs at fsfe dot org" <gcc-bugzilla@gcc.gnu.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 [thread overview] Message-ID: <bug-107202-4@http.gcc.gnu.org/bugzilla/> (raw) 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?
reply other threads:[~2022-10-10 19:32 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107202-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).