https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104386
Bug ID: 104386 Summary: no_unique_address causes invalid member alignment of pod struct Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at ebasoft dot com.pl Target Milestone: --- struct base { [[no_unique_address]] uint32_t x; std::byte v; }; struct foo : public base { std::byte z; }; gcc sizeof(foo) == 8 https://godbolt.org/z/G4Mo3PdKT clang sizeof(foo) == 12 https://godbolt.org/z/bdzvaMn9c As I was told it is gcc bug https://www.reddit.com/r/cpp/comments/sjx2mk/no_unique_addres_where_can_in_c_standard_instead/ [orbital1337]"Your class base is a POD but its not a POD for the purpose of layout (since it has potentially overlapping data members). Thus the Itanium ABI specifies that it's size without padding (dsize) should be set to its size with padding (sizeof). The first datamember of your class foo is put at dsize(base). clang does the right thing and puts it at an offset of 8 bytes whereas gcc ignores that one line of the specification and puts it at an offset of 5 bytes instead."