digitalmars.D.bugs - [Issue 16197] New: [The D Bug Tracker]
- via Digitalmars-d-bugs (65/65) Jun 23 2016 https://issues.dlang.org/show_bug.cgi?id=16197
https://issues.dlang.org/show_bug.cgi?id=16197 Issue ID: 16197 Summary: [The D Bug Tracker] Product: D Version: D2 Hardware: All URL: http://dlang.org/ OS: All Status: NEW Severity: major Priority: P3 Component: dmd Assignee: nobody puremagic.com Reporter: eyal weka.io Post-blit not being called properly: import std.stdio:writeln; struct Elem { int x = -1; this(int x) { this.x = x; writeln("CTOR ", x); } this(this) { writeln("POSTBLIT ", x); } ~this() { if (x!=-1) writeln("DTOR " , x); } } struct Ctr { Elem[3] arr; Elem[] slice() { return arr; } Elem[3] arrVal() { return arr; } } void main() { auto p = Ctr(); p.arr = [Elem(1), Elem(2), Elem(3)]; { writeln("slice rval -> arr {"); Elem[3] _arr = p.slice; writeln("}"); } { writeln("arr rval -> arr {"); Elem[3] _arr = p.arrVal(); writeln("}"); } } Prints out: CTOR 1 CTOR 2 CTOR 3 slice rval -> arr { } DTOR 3 DTOR 2 DTOR 1 arr rval -> arr { POSTBLIT 1 POSTBLIT 2 POSTBLIT 3 } DTOR 3 DTOR 2 DTOR 1 DTOR 3 DTOR 2 DTOR 1 Note that there are more DTOR's than CTOR/POSTBLITS. I believe dmd should maintain the same number of CTOR+POSTBLIT calls as DTOR calls, or all user invariants get broken. --
Jun 23 2016