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.
  • [Bug c++/98071] New: no_unique_... barry.revzin at gmail dot com via Gcc-bugs

Reply via email to