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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 29 19:16:27 UTC 2019


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

kinke at gmx.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke at gmx.net

--- Comment #3 from kinke at gmx.net ---
I've just seen that LDC handles this differently than DMD. With LDC, an
explicit initializer takes precedence, regardless of the lexical order:

union S
{
    int x; // compiler error if also explicitly initialized (except for `=
void`)
    float y = 1.0f;
}

void main()
{
    S s;
    assert(s.y == 1.0f);
}

--


More information about the Digitalmars-d-bugs mailing list