<div dir="ltr">On 29 October 2013 13:47, growler <span dir="ltr"><<a href="mailto:growlercab@gmail.com" target="_blank">growlercab@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tuesday, 29 October 2013 at 00:45:59 UTC, Manu wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On 29 October 2013 04:33, monarch_dodra <<a href="mailto:monarchdodra@gmail.com" target="_blank">monarchdodra@gmail.com</a>> wrote:<br>
<br>
</div><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Monday, 28 October 2013 at 02:44:54 UTC, Manu wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I had a lot of informal conversations with Walter trying to get my head<br>
around the details here.<br>
To my recollection, the intent was that it should behave like C, and that<br>
S.alignof must certainly == 128 in that case. It can't work otherwise.<br>
Alignment must be inherited by parent structures.<br>
<br>
</blockquote>
<br>
But is that really what it means though? From the above conversation, it<br>
would instead appear to mean that:<br>
struct S<br>
{<br>
int i;<br>
align(128) int j;<br>
}<br>
in this case, the *padding* needed until we reach j is 128 bytes.<br>
<br>
It doesn't mean that S itself need to be 128 aligned.<br>
</blockquote>
<br>
<br></div><div class="im">
Both should be true, if it's not, it's a bug.<br>
<br>
</div></blockquote>
<br>
<a href="http://dlang.org/attribute.html#align" target="_blank">http://dlang.org/attribute.<u></u>html#align</a><br>
---<br>
The alignment for the fields of an aggregate does not affect the alignment of the aggregate itself - that is affected by the alignment setting outside of the aggregate.<br>
<br>
align (2) struct S {<br>
align (1):<br>
byte a; // placed at offset 0<br>
int b; // placed at offset 1<br>
long c; // placed at offset 5<br>
}<br>
<br>
auto sz = S.sizeof; // 14<br>
---<br>
<br>
My understanding of that is S is not affected by the alignment of its fields.<br>
</blockquote></div><br></div><div class="gmail_extra">This is a strange test.</div><div class="gmail_extra">It looks like your align(1) is intended to mean pack(1), and if that is the case, then the observed sizeof is correct.</div>
<div class="gmail_extra">with pack(1), the size would be 8+4+1 = 13, but then the struct marked align(2) must be padded to a multiple of it's alignment, so 14.</div><div class="gmail_extra">What you observe is probably correct, except I don't think the use of align(1) to mean pack(1) is right. That should raise discussion...</div>
</div>