From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C6E823858004; Thu, 11 Mar 2021 00:51:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6E823858004 From: "Darrell.Wright at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Darrell.Wright at gmail dot com 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Mar 2021 00:51:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99535 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=20 struct Thing0 { volatile int a; constexpr Thing0( int v ): a{v} {} constexpr Thing0(Thing0 const& other) : a(other.a) {} constexpr Thing0& operator=3D(Thing0 const& rhs) { a =3D rhs.a; return *this; } ~Thing0() =3D default; }; Thing0 func0() { return Thing0{5}; } : In copy constructor 'constexpr Thing0::Thing0(const Thing0&)': :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) {} | ~~~~~~^ : In member function 'constexpr Thing0& Thing0::operator=3D(const Thing0&)': :9:13: error: lvalue-to-rvalue conversion of a volatile lvalue 'rhs.Thing0::a' with type 'const volatile int' 9 | a =3D rhs.a; | ~~~~^ The code should be accepted and is when the special methods are not constex= pr.=