[Issue 23337] New: Wrongly elided postblit/copy ctor for array construction (_d_arrayctor lowering)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Sep 15 16:16:49 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23337
Issue ID: 23337
Summary: Wrongly elided postblit/copy ctor for array
construction (_d_arrayctor lowering)
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: kinke at gmx.net
The following code worked for DMD v2.085-2.090, but regressed with v2.091 and
still fails with current DMD master, after the templated `_d_arrayctor`
introduction:
```
void main() {
int copies;
struct S
{
int i;
this(this) { ++copies; }
//this(inout ref S) inout { ++copies; }
}
import core.lifetime;
S[2] ss1 = void;
S[2] ss2;
emplace(&ss1, ss2);
assert(copies == 2);
copies = 0;
emplace(&ss1, ss2[]);
assert(copies == 2); // fails (is 0)
}
```
[It works just fine with LDC though.] This came up when bumping LDC's frontend,
as the glue layer would still lower this to old untemplated `_d_arrayctor`. So
the frontend misses the new templated `_d_arrayctor` lowering in this case; the
according buggy logic is probably here:
https://github.com/dlang/dmd/blob/638de4022d1b2d7a8f529d8b81c7916a958bbe9d/compiler/src/dmd/expressionsem.d#L9913-L9923
--
More information about the Digitalmars-d-bugs
mailing list