https://issues.dlang.org/show_bug.cgi?id=19516

--- Comment #2 from [email protected] ---

(In reply to kinke from comment #1)
> 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

Thanks for the quick reply and clarification of the issue. I'll be using the
workaround for now.

--

Reply via email to