[Issue 7396] Indicate default alignment with 0.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 29 14:41:29 PST 2012


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



--- Comment #2 from Dan G. <venix1 at gmail.com> 2012-01-29 14:41:27 PST ---
(In reply to comment #1)
> I'm really not understanding this.
> 
> "align" by itself means default alignment. How that would differ from align(0)
> escapes me.

The problem is how the front end treats "align".  

---

struct B
{
    align:
    char a;
}

$ dmd -o- align.d -H 

// D import file generated from 'align.d'
// Notice align became align (8)
struct B
{
    align (8) char a;

}

---

That treatment of "align" conflicts with what's in the specification.

"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."

The front end has no way to indicate default alignment is what the user wants
and is effectively rewriting the default alignment expression to be an Integer
alignment expression.

By setting "n = 0" instead of "n = global.structalign" if clearly indicates to
the compiler default alignment is desired.  This is beneficial for when the
default compiler is not DMD.  

A description of GCC's aligned attribute which GDC attempted to mimic.
http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#Variable-Attributes

-- 
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