digitalmars.D.bugs - [Issue 8566] New: Inconsistency in aligning named and anonymous structs
- d-bugmail puremagic.com (45/45) Aug 20 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8566
- d-bugmail puremagic.com (13/13) Aug 20 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8566
http://d.puremagic.com/issues/show_bug.cgi?id=8566 Summary: Inconsistency in aligning named and anonymous structs Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: m.strashun gmail.com --- Comment #0 from Mihail Strashun <m.strashun gmail.com> 2012-08-20 05:47:51 PDT --- Code sample: ================================================= import std.stdio; union Anonymous { char[9] buffer; align(1) struct { align(1): int a; int b; char c; } } union Named { char[9] buffer; align(1) struct Name { align(1): int a; int b; char c; } } void main() { writeln(Named.sizeof); writeln(Anonymous.sizeof); } ================================================= Output: 9 12 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 20 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8566 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |INVALID --- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2012-08-20 15:23:26 PDT --- An unnamed struct/union allocates storage for its members. A named one does not, it just defines a type. Hence the size difference. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 20 2012