public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "Darrell.Wright at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99535] New: g++ rejects valid code in constexpr copy ctor and volatile submember Date: Thu, 11 Mar 2021 00:51:39 +0000 [thread overview] Message-ID: <bug-99535-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99535 Bug ID: 99535 Summary: g++ rejects valid code in constexpr copy ctor and volatile submember Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Darrell.Wright at gmail dot com Target Milestone: --- The following code produces an error struct Thing0 { volatile int a; constexpr Thing0( int v ): a{v} {} constexpr Thing0(Thing0 const& other) : a(other.a) {} constexpr Thing0& operator=(Thing0 const& rhs) { a = rhs.a; return *this; } ~Thing0() = default; }; Thing0 func0() { return Thing0{5}; } <source>: In copy constructor 'constexpr Thing0::Thing0(const Thing0&)': <source>:7:51: error: lvalue-to-rvalue conversion of a volatile lvalue 'other.Thing0::a' with type 'const volatile int' 7 | constexpr Thing0(Thing0 const& other) : a(other.a) {} | ~~~~~~^ <source>: In member function 'constexpr Thing0& Thing0::operator=(const Thing0&)': <source>:9:13: error: lvalue-to-rvalue conversion of a volatile lvalue 'rhs.Thing0::a' with type 'const volatile int' 9 | a = rhs.a; | ~~~~^ The code should be accepted and is when the special methods are not constexpr.
next reply other threads:[~2021-03-11 0:51 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-11 0:51 Darrell.Wright at gmail dot com [this message] 2021-03-11 1:00 ` [Bug c++/99535] " Darrell.Wright at gmail dot com 2021-03-11 13:24 ` redi 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-99535-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).