public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98071] New: no_unique_address and reusing tail padding
@ 2020-11-30 19:10 barry.revzin at gmail dot com
  2020-11-30 19:24 ` [Bug c++/98071] " barry.revzin at gmail dot com
  2021-11-27 23:08 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: barry.revzin at gmail dot com @ 2020-11-30 19:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98071

            Bug ID: 98071
           Summary: no_unique_address and reusing tail padding
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Simple example:

struct A {
    int x;
    char y;
};

template <class T>
struct B {
    [[no_unique_address]] T t;
    bool u;
};

static_assert(sizeof(B<A>) == sizeof(A));

The data member "t" is potentially-overlapping, and its three bytes of padding
could be used to fit the "u" member. But gcc doesn't do this at the moment, and
so sizeof(B<A>) is 12. On clang, sizeof(B<A>) is 8, as desired.

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

* [Bug c++/98071] no_unique_address and reusing tail padding
  2020-11-30 19:10 [Bug c++/98071] New: no_unique_address and reusing tail padding barry.revzin at gmail dot com
@ 2020-11-30 19:24 ` barry.revzin at gmail dot com
  2021-11-27 23:08 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: barry.revzin at gmail dot com @ 2020-11-30 19:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98071

--- Comment #1 from Barry Revzin <barry.revzin at gmail dot com> ---
On further discussion, since the ABI disallows reusing the tail padding of
PODs, sizeof(B<A>) cannot be 8. This is more likely a clang bug.

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

* [Bug c++/98071] no_unique_address and reusing tail padding
  2020-11-30 19:10 [Bug c++/98071] New: no_unique_address and reusing tail padding barry.revzin at gmail dot com
  2020-11-30 19:24 ` [Bug c++/98071] " barry.revzin at gmail dot com
@ 2021-11-27 23:08 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-27 23:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98071

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Invalid as mentioned.

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

end of thread, other threads:[~2021-11-27 23:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-30 19:10 [Bug c++/98071] New: no_unique_address and reusing tail padding barry.revzin at gmail dot com
2020-11-30 19:24 ` [Bug c++/98071] " barry.revzin at gmail dot com
2021-11-27 23:08 ` pinskia 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).