union.sizeof

zabruk70 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Mar 25 15:37:39 PDT 2017


//DMD 2.073.1 and latest 2.075.0-master-972eaed
//Windows 7 32-bit

union Union1
{
   align(1):
   byte[5] bytes5;
   struct
   {
     align(1):
     char char1;
     uint int1;
   }
}

void main ()
{
   import std.stdio: writefln;
   writefln("Union1.sizeof=%d", Union1.sizeof);  //prints 8, not 5
}

I expect size of Union1 is 5 (5 bytes == char + uint == 5).
Is this my bug or DMD?
Can anybody reproduce?


More information about the Digitalmars-d-learn mailing list