From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9AEAA3858D35; Fri, 5 May 2023 11:56:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9AEAA3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683287776; bh=ftpZ/dY9KB6pTEZz/90AHHL1Q7yYf+O3idrtaBuL+lc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=beS9ixr5X6OfIgIwsQGyY9CwOrbX4aRqcHorW0ouLOFYuPlsQQFFBzIdpMDSzH5uJ 7HHp3xvp+E3ShbfnClwzbX09Ga5AT8kiyf1se3uIpXCGo+cqa2Gdi8KNiV28hmZ2r/ FTCnM44NaB4LS/+iI/mBYpcevm7jZ+efmqteNbhA= From: "albin at yahoo dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109745] Incorrect code generated with -O1 when having a constexpr object modifying a mutable member Date: Fri, 05 May 2023 11:56:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: albin at yahoo 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: cc Message-ID: In-Reply-To: References: 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=3D109745 albin changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |albin at yahoo dot com --- Comment #2 from albin --- Simpler example: #include template struct Foo { T val; }; class Bar { public: constexpr Bar() =3D default; constexpr Bar(Bar const& other) { other.val_ =3D 42; } constexpr int val() const { return val_; } private: mutable int val_{}; }; int main() { constexpr Foo x{}; Foo y{x}; assert(x.val.val() =3D=3D 42); }=