On Friday, 9 January 2015 at 00:23:47 UTC, bearophile wrote:
Luc Bourhis:

With "auto a = new double[1000]", is there any guarantee that a.ptr is aligned on a 16-byte boundary?

Arrays are aligned on a 16-byte.

Good news!

But if you slice them, this alignment can be broken.

Yes, of course. It's part of the game to prevent alignment-breaking slices.

In past I suggested to put the alignment of an array in the D type system, as an optional extra information (if the alignment is not correct this causes compile-time errors in some cases and some run-time errors when the slicing bounds are runtime values).

I like the general idea. But it would seem more natural to me if a slice returned an aligned array if possible, otherwise a misaligned one.

Thanks for your thorough answer!

Reply via email to