[Issue 19516] Alignment of members & size of structs inconsistent with C
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Dec 26 16:24:27 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19516
kinke at gmx.net changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kinke at gmx.net
--- Comment #1 from kinke at gmx.net ---
This is caused by how D treats *anonymous* nested structs and unions - their
fields are correctly merged into the containing aggregate (alignment etc. is
fine), but the tail padding of that nested struct/union isn't applied to the
offsets of the following fields (which is most likely a bug).
I.e., this ugly workaround works as expected:
struct s {
static union U { double d; char[20] cs; }
U u;
char b;
alias u this;
}
pragma(msg, s.b.offsetof); // 24
pragma(msg, s.sizeof); // 32
--
More information about the Digitalmars-d-bugs
mailing list