[Issue 7396] Indicate default alignment with 0.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 30 03:09:52 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7396



--- Comment #8 from Iain Buclaw <ibuclaw at ubuntu.com> 2012-01-30 03:09:44 PST ---
(In reply to comment #6)
> I would suggest the problem is with the way gdc is doing alignment.
> 
>     align:
> 
> means the default alignment that matches the C compiler. dmd and gdc need to do
> whatever it takes to make that happen. Adding another align directive just
> confuses things.


>From the spec:
---
Align Attribute specifies the alignment of struct members. align by itself sets
it to the default, which matches the default member alignment of the companion
C compiler.
---

GDC matches the companion GCC compiler, in that we have a callback to get the
field alignment for the type, which may not necessarily the same as the type
alignment, as some architectures (i.e. i386) limit struct field alignment to a
lower boundary than alignment of some types of variables.



>From the spec:
---
Integer specifies the alignment which matches the behavior of the companion C
compiler when non-default alignments are used. 
---

GDC matches the companion GCC compiler here as well, in that:

struct S {
    align(4) byte a; // placed at offset 0
    align(4) byte b; // placed at offset 4
}

This is achieved by adding a declalign field in VarDeclaration that takes
precedence over the type align.

This I think is different from how DMC++ treats the align attribute, which is
where the conflict of interest arises.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list