On Saturday, 17 October 2020 at 12:44:44 UTC, Per Nordlöw wrote:
Can `align`s be inserted in S or/and T so that T is packed to 8 bytes but still aligned to 8 bytes? I don't see why this shouldn't be the default behaviour...
I though this would do the trick but not... struct S { int i; // 4 bytes short s; // 2 byte bool b; // 1 byte } static assert(S.sizeof == 8); static assert(S.alignof == 4); align(4) struct T { align(4) S s; align(1) char c; } static assert(T.alignof == 4); // TODO: static assert(T.sizeof == 8); T.sizeof is still 12 bytes, I want it to be 8.