public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gcc at jonathanmueller dot dev" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109096] New: __has_unique_object_representations does not account for unnamed bitfield Date: Fri, 10 Mar 2023 21:52:53 +0000 [thread overview] Message-ID: <bug-109096-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109096 Bug ID: 109096 Summary: __has_unique_object_representations does not account for unnamed bitfield Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at jonathanmueller dot dev Target Milestone: --- __has_unique_object_representations should return false for types that contain an unnamed bit field of non-zero bit-width, since that introduces padding bits; yet it doesn't: ``` #include <cassert> #include <cstring> struct foo { int member : 8; // We explitly introduce 24 padding bits here. int : 24; bool operator==(const foo&) const = default; }; // Yet this assertion passes?! static_assert(__has_unique_object_representations(foo)); // But we clearly don't have unique object representations: int main() { // Create two objects with different object representations. foo a, b; std::memset(&a, 0xFF, sizeof(foo)); std::memset(&b, 0x99, sizeof(foo)); // Make all members identical to give them the same value representation. a.member = 0; b.member = 0; // This passes; they have the same value representation. assert(a == b); // But this fails; they don't have unique object representations! assert(std::memcmp(&a, &b, sizeof(foo)) == 0); } ``` https://godbolt.org/z/Y4GzqYE8s
next reply other threads:[~2023-03-10 21:52 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-10 21:52 gcc at jonathanmueller dot dev [this message] 2023-03-10 22:04 ` [Bug c++/109096] " gcc at jonathanmueller dot dev 2023-03-10 22:21 ` pinskia at gcc dot gnu.org 2023-03-10 22:49 ` jakub at gcc dot gnu.org 2023-03-13 10:03 ` jakub at gcc dot gnu.org 2023-03-14 15:19 ` cvs-commit at gcc dot gnu.org 2023-03-14 15:20 ` jakub at gcc dot gnu.org 2023-03-19 5:31 ` cvs-commit at gcc dot gnu.org 2023-03-20 10:30 ` jakub at gcc dot gnu.org 2023-05-02 20:15 ` cvs-commit at gcc dot gnu.org 2023-05-03 10:43 ` jakub at gcc dot gnu.org 2023-05-03 15:22 ` cvs-commit at gcc dot gnu.org 2023-05-04 7:25 ` 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-109096-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).