[Issue 15498] Unhelpful error message "destructors, postblits and invariants are not allowed in overlapping fields"

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Mar 28 06:15:28 PDT 2016


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

--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> ---
Minimized example code that compiler shows the error message.

struct X
{
    this(this) {}
    // or: ~this() {}
    // or: invariant {}
}

union U // Error
{
    X x;
    int overlapping;
}

struct S // Error
{
    union
    {
        X x;
        int overlapping;
    }
}

For U or S, compiler cannot generate destructors, postblits, or invariants
automatically, because the field x typed X overlapping with other fields.

--


More information about the Digitalmars-d-bugs mailing list