public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95976] New: [[no_unique_address]] on union members has the opposite-of-intended effect
@ 2020-06-29 16:52 metaprogrammingtheworld at gmail dot com
  2020-06-30 11:56 ` [Bug c++/95976] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: metaprogrammingtheworld at gmail dot com @ 2020-06-29 16:52 UTC (permalink / raw)
  To: gcc-bugs

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 );
//////////

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-08-04 17:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 16:52 [Bug c++/95976] New: [[no_unique_address]] on union members has the opposite-of-intended effect metaprogrammingtheworld at gmail dot com
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

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).