[Issue 21349] New: copy and postblit constructors aren't compatible

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 29 15:56:10 UTC 2020


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

          Issue ID: 21349
           Summary: copy and postblit constructors aren't compatible
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ilyayaroshenko at gmail.com

struct SNew
{
    int s;
    this(ref return scope inout SNew rhs)  inout {
        this.s = rhs.s + 1;
        pragma(inline, false);
    }
}

struct SOld
{
    int s;
    this(this) {
        this.s++;
        pragma(inline, false);
    }
}

struct C
{
    SOld sOld;
    SNew sNew;

    this(this) {
        pragma(inline, false);
    }
}

void main()
{
    C c;
    auto d = c;
    assert(d.sOld.s);
    assert(d.sNew.s);
}

--


More information about the Digitalmars-d-bugs mailing list