[Issue 19917] New: unions should require that all members are `= void` initialised

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 28 22:28:20 UTC 2019


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: nobody at puremagic.com
          Reporter: turkeyman at gmail.com

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
  }
}

--


More information about the Digitalmars-d-bugs mailing list