Frits van Bommel wrote:
Stewart Gordon wrote:
<snip>
[rearrangement of class fields]

Right, forgot about that bit. Probably because AFAIK no D compiler actually reorganizes them...

(How does this combine with the "D ABI" anyway? I know binary compatibility between the different compilers is a bit of a pipe dream at the moment, but the only way that could work would be to standardize any and all shuffling of class fields...)

Good question. But AAs are another thing that's implementation defined at the moment.

<snip>
Unions are normally aligned to the maximum alignment for any member. Now consider:

union U {
    align(1) void* p;
    ubyte[size_t.sizeof] bytes;
}
union U2 {
    align(4) ubyte[12] data;
    char[12] str;
}
What are U.alignof and U2.alignof?

According to that piece of the spec, those align() attributes should be useless. However, according to DMD[1] U.alignof is 1, and without the attribute it's 4.
U2 on the other hand is align(1) regardless of attribute.
<snip>

Sounds like a bug.

Surely, align isn't applicable to unions at all. IINM the members of a union, by design, start at the same offset. An anonymous struct within a union, or an anonymous union within a struct, might have alignment - in either case, it would be in relation to the struct.

Stewart.

Reply via email to