public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109039] [12/13 Regression] Miscompilation with no_unique_address and bitfields Date: Thu, 09 Mar 2023 14:56:59 +0000 [thread overview] Message-ID: <bug-109039-4-fKezCr8roh@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109039-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109039 --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- And there doesn't even have to be any NSDMI, even struct X { short x0 : 7; short x1 : 8; X () : x0 (1), x1 (2) {} int get () { return x0 + x1; } }; struct S { [[no_unique_address]] X x; char c; S () : c (0) {} }; S s; int main () { if (s.x.x0 != 1 || s.x.x1 != 2 || s.c != 0) __builtin_abort (); } is miscompiled since that revision. With sizeof (s) == 2 there aren't enough bytes to fit the 15 bits of bitfields and another byte. S::x.x0 is on x86_64 at offset 0, low 7 bits, then S::x.x1 next 8 bits, and S::c is at offset 1, so overlapping the high 7 bits of S::x.x1.
next prev parent reply other threads:[~2023-03-09 14:56 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-06 10:46 [Bug c++/109039] New: " coillol at yandex dot ru 2023-03-06 14:44 ` [Bug c++/109039] [12/13 Regression] " ppalka at gcc dot gnu.org 2023-03-06 14:59 ` jakub at gcc dot gnu.org 2023-03-09 14:56 ` jakub at gcc dot gnu.org [this message] 2023-03-09 16:57 ` jakub at gcc dot gnu.org 2023-03-09 17:12 ` jakub at gcc dot gnu.org 2023-03-10 19:37 ` cvs-commit at gcc dot gnu.org 2023-03-10 19:45 ` [Bug c++/109039] [12 " jakub at gcc dot gnu.org 2023-03-19 5:30 ` cvs-commit at gcc dot gnu.org 2023-03-20 10:29 ` jakub 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-109039-4-fKezCr8roh@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).