public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "metaprogrammingtheworld at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95976] New: [[no_unique_address]] on union members has the opposite-of-intended effect Date: Mon, 29 Jun 2020 16:52:36 +0000 [thread overview] Message-ID: <bug-95976-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95976 Bug ID: 95976 Summary: [[no_unique_address]] on union members has the opposite-of-intended effect Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: metaprogrammingtheworld at gmail dot com Target Milestone: --- When using [[no_unique_address]] with union members, ironically, each member is now given a unique address! Without [[no_unique_address]], the layout is as one would expect. This is particularly unfortunate since it means that a union's size grows in proportion to the number of members when using [[no_unique_address]]! Example: ////////// struct empty {}; union no_attribute_t { empty _0; empty _1; }; union with_attribute_t { [[no_unique_address]] empty _0; [[no_unique_address]] empty _1; }; constexpr no_attribute_t no_attribute{}; constexpr with_attribute_t with_attribute{}; // This succeeds static_assert( &no_attribute._0 == &no_attribute._1 ); // This fails static_assert( &with_attribute._0 == &with_attribute._1 ); //////////
next reply other threads:[~2020-06-29 16:52 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-29 16:52 metaprogrammingtheworld at gmail dot com [this message] 2020-06-30 11:56 ` [Bug c++/95976] " jakub at gcc dot gnu.org 2020-06-30 12:27 ` jakub at gcc dot gnu.org 2020-07-10 3:24 ` jason at gcc dot gnu.org 2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org 2020-07-10 12:36 ` cvs-commit at gcc dot gnu.org 2020-08-04 17:35 ` jason 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-95976-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).