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 ipa/106389] New: IPA modref breaks Safe Bitfields in C++ Date: Thu, 21 Jul 2022 17:21:16 +0000 [thread overview] Message-ID: <bug-106389-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106389 Bug ID: 106389 Summary: IPA modref breaks Safe Bitfields in C++ Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: mpolacek at gcc dot gnu.org CC: marxin at gcc dot gnu.org Target Milestone: --- The following test is miscompiled since r11-3308-gd119f34c952f87 (so the problem goes away with -fno-ipa-modref). void __assert_fail(const char *, const char *, int, const char *) { __builtin_abort(); } typedef int uint32_t; template <int Offset> struct BitFieldMember { int value; operator int() { return value & 1; } BitFieldMember operator=(int v) { value = value | v << Offset; return *this; } BitFieldMember operator-=(int v) { *this ? void() : __assert_fail("", "", 9, __PRETTY_FUNCTION__); value -= v << Offset; return *this; } }; union Status { struct { uint32_t value; } wrapper; Status(uint32_t v = 0) { wrapper.value = v; } operator uint32_t() { return wrapper.value; } BitFieldMember<0> readers; BitFieldMember<10> waitToRead; BitFieldMember<20> writers; }; uint32_t u; struct N { uint32_t m_status; void foo () { Status oldStatus = m_status, newStatus = oldStatus; u = oldStatus.waitToRead; newStatus.writers -= u; newStatus.readers = u; m_status = newStatus; } }; int main() { Status status; status.writers = status = 1; N lock; lock.m_status = status; lock.foo (); if (lock.m_status != 1) __builtin_abort(); }
next reply other threads:[~2022-07-21 17:21 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-21 17:21 mpolacek at gcc dot gnu.org [this message] 2022-07-21 17:23 ` [Bug ipa/106389] [11/12/13 Regression] " mpolacek at gcc dot gnu.org 2022-07-21 17:26 ` mpolacek at gcc dot gnu.org 2022-07-22 7:09 ` [Bug c++/106389] " rguenth at gcc dot gnu.org 2022-07-22 12:53 ` mpolacek at gcc dot gnu.org 2022-07-24 9:05 ` hubicka at gcc dot gnu.org 2022-07-25 6:20 ` rguenth at gcc dot gnu.org 2023-05-29 10:07 ` [Bug c++/106389] [11/12/13/14 " jakub at gcc dot gnu.org 2023-07-08 1:45 ` pinskia at gcc dot gnu.org 2023-10-30 20:09 ` pinskia 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-106389-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).