From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 882803858D38; Fri, 10 Mar 2023 21:52:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 882803858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678485173; bh=Nm9/JJyRs6HTlplZXgZavtGhyFB9B6G8JbgP3cTMCVM=; h=From:To:Subject:Date:From; b=NZM0M88EvP/K+H81L+VEnJRtpUF0YJGXxbC3V0xyt0i1OuQ0XnYo9tQ2ckb4l+bEb ZGCbF7Ed6/RH56xhBn/m0auu61vzNMp6aIhwMHqp2JnYtUYKzK6kFsjn74Vmuq7hE5 waybPxrW6CWPQ3jup2ROQ3j6m3UdVAhKPmuntMyg= From: "gcc at jonathanmueller dot dev" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc at jonathanmueller dot dev X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109096 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 cont= ain an unnamed bit field of non-zero bit-width, since that introduces padding b= its; yet it doesn't: ``` #include #include struct foo { int member : 8; // We explitly introduce 24 padding bits here. int : 24; bool operator=3D=3D(const foo&) const =3D 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 representatio= n. a.member =3D 0; b.member =3D 0; // This passes; they have the same value representation. assert(a =3D=3D b); // But this fails; they don't have unique object representations! assert(std::memcmp(&a, &b, sizeof(foo)) =3D=3D 0); } ``` https://godbolt.org/z/Y4GzqYE8s=