Target field alignment returned by GDC (and probably LDC too) is being overwritten/ignored by the frontend if it considers it wrong from an x86 standpoint.
Here's one example that affects both DMD and GDC for different reasons.
---
struct vec_struct {
bool b2;
struct {
bool b;
int8 field;
}
}
static assert(vec_struct.b.offsetof == 32); // Fails, offset == 8
static assert(vec_struct.field.offsetof == 64); // Fails, offset == 40 !!!
---
Comment #1 by ibuclaw — 2017-03-01T22:11:43Z
On a mild ranting note, this is the offender in the frontend.
---
// AggregateDeclaration.placeField (aggregate.d)
if ((global.params.is64bit || global.params.isOSX) && memalignsize == 16)
{
}
else if (8 < memalignsize)
memalignsize = 8;
---
For DMD - you seem to have forgotten that you support 256-bit vectors.
For GDC, you're ignoring the target-specific alignment of fields that we return, instead enforcing that everything must fit your x86 view of ABI.
This piece of code should be moved to Target::fieldalign where it deservedly belongs.
Comment #2 by github-bugzilla — 2017-03-02T02:21:10Z