[Bug c++/104386] no_unique_address causes invalid member alignment of pod struct
gcc at ebasoft dot com.pl
gcc-bugzilla@gcc.gnu.org
Sun Feb 6 10:26:26 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104386
--- Comment #2 from Artur Bać <gcc at ebasoft dot com.pl> ---
I think it is connected with this case
https://godbolt.org/z/cvfs1KqGW
https://godbolt.org/z/vdzTzo7be
//sizeof(foo) ==12
struct base
{
uint32_t x{};
std::byte v{};
base() noexcept = default;
};
struct foo : public base
{
std::byte z;
};
//sizeof(foo) == 8
struct base
{
uint32_t x;
std::byte v;
base() noexcept : x{}, v{} {}
};
struct foo : public base
{
std::byte z;
};
and
https://www.reddit.com/r/cpp/comments/slfugx/comment/hvs4n7j/?utm_source=share&utm_medium=web2x&context=3
"Som1Lse · 5 hr. ago
Interestingly GCC disagrees with itself:
-std=c++17 it considers base to be a POD and doesn't reuse padding.
-std=c++20 it considers base to not be a POD and agrees with Clang, reusing
the padding bytes."
More information about the Gcc-bugs
mailing list