Class instance alignment

tsbockman thomas.bockman at gmail.com
Sat Feb 20 07:13:32 UTC 2021


On Saturday, 20 February 2021 at 05:44:33 UTC, kinke wrote:
> There's 
> https://github.com/dlang/druntime/blob/728f1d9c3b7a37eba4d59ee2637fb924053cba6d/src/core/internal/traits.d#L261.

Thanks! That's helpful.

> But AFAIK, the GC only guarantees an alignment of 16 and 
> doesn't respect any overaligned members or alignment spec for 
> the class.

Well, that's just another reason not to use the GC for my current 
project, then: I'm using 256-bit AVX vectors extensively.

That alignment limit really *needs* to be raised to at least 32 
bytes, given that even DMD has some support for AVX. 64 bytes 
would be better, since AVX512 is going mainstream soon. And, 128 
bytes is the largest common cache line size, I think?

If raising the limit is considered unacceptable for some reason, 
then trying to allocate something with an unsupported alignment 
should be an error instead of just silently doing the wrong thing.


More information about the Digitalmars-d-learn mailing list