[Issue 8355] struct's sizeof has bug

2012-07-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8355



--- Comment #4 from Walter Bright  2012-07-07 
16:11:40 PDT ---
align inside sets the alignment of the fields. align outside sets the alignment
of the instance as a single block.

So, you'll need both to get an unaligned size.

For example, consider an array of S. It should be an even multiple of the size
of S. So consider how alignment must play into that, and the behavior becomes
inevitable.

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


[Issue 8355] struct's sizeof has bug

2012-07-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8355


bearophile_h...@eml.cc changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc


--- Comment #3 from bearophile_h...@eml.cc 2012-07-07 13:58:13 PDT ---
(In reply to comment #2)
> If you're using head, you'll need to put the align(1) inside the struct
> declaration, rather than outside. The layout is now only affected by align
> attributes that are inside the declaration.

What's the right syntax? This prints three times 28:


struct Foo1 {
align(1):
ushort a,b,c,d,e;
uint f, g, h;
ushort i, j;
}
pragma(msg, Foo1.sizeof);

struct Foo2 {
align(1) {
ushort a,b,c,d,e;
uint f, g, h;
ushort i, j;
}
}
pragma(msg, Foo2.sizeof);

struct Foo3 {
align(1) ushort a,b,c,d,e;
align(1) uint f, g, h;
align(1) ushort i, j;
}
pragma(msg, Foo3.sizeof);

void main() {}



While this prints 26:

align(1) struct Foo4 {
align(1):
ushort a,b,c,d,e;
uint f, g, h;
ushort i, j;
}
pragma(msg, Foo4.sizeof);
void main() {}

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


[Issue 8355] struct's sizeof has bug

2012-07-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8355


Walter Bright  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||INVALID


--- Comment #2 from Walter Bright  2012-07-07 
13:21:52 PDT ---
If you're using head, you'll need to put the align(1) inside the struct
declaration, rather than outside. The layout is now only affected by align
attributes that are inside the declaration. Align attributes outside affect how
the struct is aligned where the struct instance is placed.

I.e. this is an intentional change.

The previous behavior was broken in some respects, and was incompatible with
doing things like having 256 byte alignment. Furthermore, the specific behavior
of putting align outside and having it affect the inside was a bug.

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


[Issue 8355] struct's sizeof has bug

2012-07-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8355


Nils  changed:

   What|Removed |Added

 CC||mailm...@nilsb.dyndns.org
   Severity|normal  |regression


--- Comment #1 from Nils  2012-07-07 12:54:29 PDT ---
printed "26" before
https://github.com/D-Programming-Language/dmd/commit/154e44a006270d53745f99ec3e538a0ce526ae76

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