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

--- Comment #2 from Paul Backus <snarwin+bugzi...@gmail.com> ---
Yes, because the data can still be modified by assigning a new value to the
whole union.

---
void oops()
{
    U a = { y: 0 };
    U b = { x: 1 };
    assert(a.y == 0);
    a = b;
    assert(a.y == 1);
}
---

Strictly speaking, the problem is that we are allowed to access a.y after its
lifetime has ended. However, this only leads to undefined behavior when unsafe
aliasing is involved, so the unsafe aliasing is what needs to be fixed.

--

Reply via email to