On 03/25/2017 11:37 PM, zabruk70 wrote:
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'm not sure how the align stuff is supposed to work exactly, but you get 5 when you add `align(1)` to the union itself, too:

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

pragma(msg, Union1.sizeof); /* "5LU" */
----

Reply via email to