June 14, 2012
>> Cause align doesn't work the way you think it does.
>> In fact I still don't understand how it works at all.
>
> The language align keyword can only reduce the alignment from the platform default (typically 8).  A serious flaw if you ask me . . . .

The doc page doesn't even clearly state this, it is incomprehensible imo: http://dlang.org/attribute.html#align

"align by itself sets it to the default, which matches the default member alignment of the companion C compiler. Integer specifies the alignment which matches the behavior of the companion C compiler when non-default alignments are used."
What the heck is this supposed to mean? It sounds like in any case the C compiler's value is used and the attribute is completely superfluous/useless.
June 14, 2012
On Thursday, 14 June 2012 at 12:02:02 UTC, Trass3r wrote:
> What the heck is this supposed to mean? It sounds like in any case the C compiler's value is used and the attribute is completely superfluous/useless.

It means it works like C's _Alignas ( constant-expression ) (C11, 6.7.5).
June 17, 2012
On Monday, 11 June 2012 at 03:19:08 UTC, ixid wrote:
>     struct a
>     {   align(16) int[4] test = [1,2,3,4];
>     }
>     a test;
>
>     asm
>     {
>             movdqa XMM0, test   ;
>             addps XMM0, XMM0    ;
>             movdpa test, XMM0   ;
>     }
>
> This works fine with unaligned movdqu but throws an access violation exception with movdqa. Why isn't align letting me do an aligned read? How should I do an aligned read?

IIRC, you're supposed to be able to do something like align(16) struct a, but it doesn't work when a is created on the stack. That was the conclusion I found when trying to implement my own vector type a year ago anyways.
1 2
Next ›   Last »