https://issues.dlang.org/show_bug.cgi?id=19917

          Issue ID: 19917
           Summary: unions should require that all members are `= void`
                    initialised
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

Unions should require that all members are `= void` initialised.
Perhaps allow just one union member to omit the `= void` initialisation... but
zero would also be fine.

It's not possible that 2 or more members express initialisation intent, and it
should be a compile error.

struct S
{
  union
  {
    int x;
    float y; // COMPILE ERROR, 'x' already initialised!
  }

  union
  {
    int z;
    float w = void; // <- this is fine
  }
}

--

Reply via email to