www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19680] New: [REG2.085.0-beta.1] Uda inside union breaks

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

          Issue ID: 19680
           Summary: [REG2.085.0-beta.1] Uda inside union breaks default
                    initialization
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: zero vec4.xyz

Code:
----
struct MyInnerStruct {            
    union {
         ("BRAKE_ME") int[2] v = 0;        
        struct { int x, y; }
    }

    this(int vx, int vy) {
        x = vx; y = vy;
    }
}


struct MyStruct {  
    MyInnerStruct inner = MyInnerStruct(1, 2);
}


void main()
{
    {
        MyStruct ok = MyStruct();            
        assert(ok.inner.v == [1, 2]);
    }

    {
        MyStruct err;            
        assert(err.inner.v == [1, 2]);
    }  
}
---


run.dlang.io:
https://run.dlang.io/is/fzj0IM

--
Feb 16 2019