On Saturday, 7 August 2021 at 14:34:49 UTC, Tejas wrote:

Umm, the ```align array``` solution is flat out wrong, please ignore it. Most likely a bug in the compiler.

Also, why will the address of the first element of the array ```modulo``` alignment be 0? The address of the array has absolutely nothing to do with the alignment.

You say that the ```align array``` solution has the expected spacing, but it is default aligned, totally ignoring your 64 byte requirement.

Don't use ```x.PTR%ALIGNMENT```
Use ```(&x[1]-&[2])%ALIGNMENT```

You will get ALIGNMENT*(2 -1)(since you took difference of 2nd and 1st elem)

For the array as a whole to be aligned, not only must the spacing between the elements respect the alignment, but starting address of the array itself must be a multiple of the alignment. So it is correct to check that `x.ptr%ALIGNMENT == 0`.

The issue with `align` attributes being ignored for stack variables is apparently a known bug, first reported in 2016: https://issues.dlang.org/show_bug.cgi?id=16098

The issue with `align` attributes being ignored by `new` is also a known bug, and was also first reported in 2016: https://issues.dlang.org/show_bug.cgi?id=16508

Reply via email to