www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21349] New: copy and postblit constructors aren't compatible

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 puremagic.com
          Reporter: ilyayaroshenko 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);
}

--
Oct 29 2020