[ABI] Type with potentially-overlapping member (`[[no_unique_address]]`) still considered POD for the purpose of layout
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#POD
However, a type is not considered to be a POD for the purpose of layout if it is:
- [...]
- a POD-struct with one or more potentially-overlapping non-static data members.
Clang does not seem to respect this. This is visible when tail-padding is not reused
https://github.com/llvm/llvm-project/blob/216787cffc4a864e0effb165c1c32b92328a0a06/clang/lib/AST/RecordLayoutBuilder.cpp#L2421
struct X { // Not POD for the purpose of layout
[[no_unique_address]] alignas(4) char a; // potentially-overlapping
};
struct Y : X {
char b; // This should be in the tail-padding
};
static_assert(sizeof(Y) == 4);
Clang makes sizeof(Y) == 8, disagreeing with GCC
@llvm/issue-subscribers-clang-frontend
Author: Mital Ashok (MitalAshok)
> However, a type is not considered to be a POD for the purpose of layout if it is: > - [...] > - a POD-struct with one or more potentially-overlapping non-static data members.
Clang does not seem to respect this. This is visible when tail-padding is not reused
https://github.com/llvm/llvm-project/blob/216787cffc4a864e0effb165c1c32b92328a0a06/clang/lib/AST/RecordLayoutBuilder.cpp#L2421
struct X { // Not POD for the purpose of layout
[[no_unique_address]] alignas(4) char a; // potentially-overlapping
};
struct Y : X {
char b; // This should be in the tail-padding
};
static_assert(sizeof(Y) == 4);
Clang makes sizeof(Y) == 8, disagreeing with GCC
Dupe of https://github.com/llvm/llvm-project/issues/50766?