public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104386] New: no_unique_address causes invalid member alignment of pod struct
@ 2022-02-04 17:43 gcc at ebasoft dot com.pl
2022-02-04 21:55 ` [Bug c++/104386] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: gcc at ebasoft dot com.pl @ 2022-02-04 17:43 UTC (permalink / raw)
To: gcc-bugs
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."
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104386] no_unique_address causes invalid member alignment of pod struct
2022-02-04 17:43 [Bug c++/104386] New: no_unique_address causes invalid member alignment of pod struct gcc at ebasoft dot com.pl
@ 2022-02-04 21:55 ` pinskia at gcc dot gnu.org
2022-02-06 10:26 ` gcc at ebasoft dot com.pl
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-04 21:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104386
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm:
https://github.com/itanium-cxx-abi/cxx-abi/issues/108
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104386] no_unique_address causes invalid member alignment of pod struct
2022-02-04 17:43 [Bug c++/104386] New: no_unique_address causes invalid member alignment of pod struct 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
2022-02-06 23:10 ` pinskia at gcc dot gnu.org
2022-03-29 15:05 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: gcc at ebasoft dot com.pl @ 2022-02-06 10:26 UTC (permalink / raw)
To: gcc-bugs
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."
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104386] no_unique_address causes invalid member alignment of pod struct
2022-02-04 17:43 [Bug c++/104386] New: no_unique_address causes invalid member alignment of pod struct 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
@ 2022-02-06 23:10 ` pinskia at gcc dot gnu.org
2022-03-29 15:05 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-06 23:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104386
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |blocker
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104386] no_unique_address causes invalid member alignment of pod struct
2022-02-04 17:43 [Bug c++/104386] New: no_unique_address causes invalid member alignment of pod struct gcc at ebasoft dot com.pl
` (2 preceding siblings ...)
2022-02-06 23:10 ` pinskia at gcc dot gnu.org
@ 2022-03-29 15:05 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-29 15:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104386
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-03-29
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-29 15:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 17:43 [Bug c++/104386] New: no_unique_address causes invalid member alignment of pod struct 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
2022-02-06 23:10 ` pinskia at gcc dot gnu.org
2022-03-29 15:05 ` redi at gcc dot gnu.org
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).