[Issue 20342] New: GDC - assignment to anonymous union member corrupts data

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 31 01:16:02 UTC 2019


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

          Issue ID: 20342
           Summary: GDC - assignment to anonymous union member corrupts
                    data
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: sahmi.soulaimane at gmail.com

```
union U
{
    struct
    {
        size_t a;
        size_t b;
        union
        {
            size_t c;
            size_t d;
        }
    }
}

void main()
{
    U u;
    assert(u.a == 0); // ok
    u.d = 1;
    assert(u.a == 0); // error
}
```

--


More information about the Digitalmars-d-bugs mailing list