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 16:57:52 +0000 [thread overview] Message-ID: <bug-109039-4-i7nm5NBkwm@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 #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I think the bug is in class.cc (end_of_class), which does: offset = size_binop (PLUS_EXPR, byte_position (field), size); That works fine for non bit-fields, but for bit-fields it is sometimes incorrect. In particular, X::x1 has DECL_SIZE 8, DECL_SIZE_UNIT 1, DECL_FIELD_OFFSET 0, DECL_FIELD_BIT_OFFSET 7. So, byte_position (field) is still 0, and size 1, therefore offset is set to 1, even when the bit-field occupies just 1 bit in the first byte and 7 in the second byte, so I think we want to set offset to 2 in this case. The Itanium ABI says: In either case, update dsize(C) to include the last byte containing (part of) the bit-field, and update sizeof(C) to max(sizeof(C),dsize(C)). So, I think for bit-fields we instead want to sum bit_position (field) and DECL_SIZE and CEIL_DIV_EXPR it by bitsize_unit_node and cast to sizetype.
next prev parent reply other threads:[~2023-03-09 16:57 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 2023-03-09 16:57 ` jakub at gcc dot gnu.org [this message] 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-i7nm5NBkwm@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).