www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19822] New: 2.086 regression wrt. union initializers

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

          Issue ID: 19822
           Summary: 2.086 regression wrt. union initializers
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: kinke gmx.net

This assertion fails since 2.086.0-beta.1: https://run.dlang.io/is/YvQvyE

struct Quat
{
    static struct Vec { int x; }

    union
    {
        Vec v;
        struct { float x; }
    }

    static Quat identity()
    {
        Quat q;
        q.x = 1.0f;
        return q;
    }
}

struct QuatContainerWithIncompatibleInit
{
    Quat q = Quat.identity;
}

void main()
{
    QuatContainerWithIncompatibleInit c;
    assert(c.q.x == 1.0f); // fails
}

--
Apr 24 2019