The great inapplicable attribute debate

Stewart Gordon smjg_1998 at yahoo.com
Mon Apr 13 05:53:32 PDT 2009


Frits van Bommel wrote:
> Kagamin wrote:
<snip>
>> Such mood was always in the spec: "AlignAttribute is ignored when 
>> applied to declarations that are not structs or struct members".
> 
> I never saw that before. So it doesn't work for class members?

http://www.digitalmars.com/d/1.0/class.html
"The D compiler is free to rearrange the order of fields in a class to 
optimally pack them in an implementation-defined manner. Consider the 
fields much like the local variables in a function - the compiler 
assigns some to registers and shuffles others around all to get the 
optimal stack frame layout. This frees the code designer to organize the 
fields in a manner that makes the code more readable rather than being 
forced to organize it according to machine optimization rules. Explicit 
control of field layout is provided by struct/union types, not classes."

> And it 
> won't change the alignment of unions if applied to union members (by 
> changing the maximum alignment of the members)?

I'm not sure what you mean....

But there seem to be a few issues with the behaviour of align.  I'll 
have to investigate....

Stewart.



More information about the Digitalmars-d mailing list