public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107598] New: implicitly-defined copy/move assignment op not constexpr Date: Wed, 09 Nov 2022 19:26:01 +0000 [thread overview] Message-ID: <bug-107598-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107598 Bug ID: 107598 Summary: implicitly-defined copy/move assignment op not constexpr Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mpolacek at gcc dot gnu.org Target Milestone: --- The following test is rejected with: bug1.C: In function ‘constexpr void g()’: bug1.C:11:7: error: call to non-‘constexpr’ function ‘S& S::operator=(const S&)’ 11 | b = a; | ^ bug1.C:5:4: note: ‘S& S::operator=(const S&)’ is not usable as a ‘constexpr’ function because: 5 | S& S::operator=(const S&) = default; | ^ ...because what? I think it should be accepted, at least in C++23, because [class.copy.assign]/10: "A copy/move assignment operator for a class X that is defaulted and not defined as deleted is implicitly defined when it is odr-used ([basic.def.odr]) (e.g., when it is selected by overload resolution to assign to an object of its class type), when it is needed for constant evaluation ([expr.const]), or when it is explicitly defaulted after its first declaration. The implicitly-defined copy/move assignment operator is constexpr." Here it is explicitly defaulted after its first declaration. struct S { constexpr S() {} S& operator=(const S&); }; S& S::operator=(const S&) = default; constexpr void g () { S a, b; b = a; }
next reply other threads:[~2022-11-09 19:26 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-09 19:26 mpolacek at gcc dot gnu.org [this message] 2022-11-16 13:27 ` [Bug c++/107598] " jason at gcc dot gnu.org 2022-11-16 14:09 ` mpolacek at gcc dot gnu.org
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-107598-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).