digitalmars.D.bugs - [Issue 14078] New: Call DTor for stack allocated objects
- via Digitalmars-d-bugs (44/44) Jan 29 2015 https://issues.dlang.org/show_bug.cgi?id=14078
https://issues.dlang.org/show_bug.cgi?id=14078 Issue ID: 14078 Summary: Call DTor for stack allocated objects Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: rswhite4 gmail.com ---- import std.stdio; class A { int id = 0; this(int the_id) { this.id = the_id; } ~this() { } } void main() { scope A a1 = new A(1); import std.conv : emplace; void[__traits(classInstanceSize, A)] buf = void; A a2 = emplace!(A)(buf, 2); } ---- Current output: Desirable output: It would be nice if D would recognize that a2 is stack allocated and treat it like a struct, so that the DTor is called at the end of the scope. --
Jan 29 2015