public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "albin at yahoo dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-109745-4-d84YVSUzgY@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109745-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109745 albin <albin at yahoo dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |albin at yahoo dot com --- Comment #2 from albin <albin at yahoo dot com> --- Simpler example: #include <cassert> template <typename T> struct Foo { T val; }; class Bar { public: constexpr Bar() = default; constexpr Bar(Bar const& other) { other.val_ = 42; } constexpr int val() const { return val_; } private: mutable int val_{}; }; int main() { constexpr Foo<Bar> x{}; Foo<Bar> y{x}; assert(x.val.val() == 42); }
next prev parent reply other threads:[~2023-05-05 11:56 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-05 9:50 [Bug c++/109745] New: " carlosgalvezp at gmail dot com 2023-05-05 9:52 ` [Bug c++/109745] " carlosgalvezp at gmail dot com 2023-05-05 11:56 ` albin at yahoo dot com [this message] 2023-05-05 15:04 ` [Bug c++/109745] [13/14 Regression] " mpolacek at gcc dot gnu.org 2023-05-11 15:01 ` ppalka at gcc dot gnu.org 2023-05-11 20:31 ` cvs-commit at gcc dot gnu.org 2023-05-11 20:32 ` [Bug c++/109745] [13 " ppalka at gcc dot gnu.org 2023-05-12 15:08 ` cvs-commit at gcc dot gnu.org 2023-05-12 15:22 ` ppalka at gcc dot gnu.org 2023-05-12 21:17 ` carlosgalvezp at gmail dot com
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-109745-4-d84YVSUzgY@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).