public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gcc at ebasoft dot com.pl" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/104386] no_unique_address causes invalid member alignment of pod struct
Date: Sun, 06 Feb 2022 10:26:26 +0000	[thread overview]
Message-ID: <bug-104386-4-GeJwjIFJIQ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104386-4@http.gcc.gnu.org/bugzilla/>

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."

  parent reply	other threads:[~2022-02-06 10:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-04 17:43 [Bug c++/104386] New: " gcc at ebasoft dot com.pl
2022-02-04 21:55 ` [Bug c++/104386] " pinskia at gcc dot gnu.org
2022-02-06 10:26 ` gcc at ebasoft dot com.pl [this message]
2022-02-06 23:10 ` pinskia at gcc dot gnu.org
2022-03-29 15:05 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104386-4-GeJwjIFJIQ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).