[Issue 23337] Wrongly elided postblit/copy ctor for array construction (_d_arrayctor lowering)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 15 18:47:37 UTC 2022


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

--- Comment #1 from kinke <kinke at gmx.net> ---
Another testcase [straight from LDC], not depending on `emplace`:

```
int numPostblit = 0, numDtor = 0;

struct S
{
    int v;
    this(this) { ++numPostblit; }
    ~this() { ++numDtor; }
}

void foo()
{
    S[4] sa = [ S(1), S(2), S(3), S(4) ];

    // helper to generate a slice rvalue
    static S[] toSlice(ref S[4] sa) { return sa[1..$]; }

    S[3] r = toSlice(sa);
}

void main()
{
    foo();
    assert(numPostblit == 3);
    assert(numDtor == 7);
}
```

--


More information about the Digitalmars-d-bugs mailing list