Setting a hard limit on slice size, is this possible?

Tejas notrealemail at gmail.com
Sat Aug 7 15:41:24 UTC 2021


On Saturday, 7 August 2021 at 15:21:01 UTC, Paul Backus wrote:
> On Saturday, 7 August 2021 at 14:34:49 UTC, Tejas wrote:
>> [...]
>
> 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

Oh wow, and here I thought I was being smart :(

So, how can we work around this without assembly language magic? 
I'm illiterate at assembly.


More information about the Digitalmars-d-learn mailing list