Bug 11351 – Destructor of "with" statement expression result is called too soon

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-25T05:05:00Z
Last change time
2013-10-25T09:57:03Z
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2013-10-25T05:05:12Z
import std.stdio; struct S { this(this) { writeln("this(this)"); } ~this() { writeln("~this()"); } } S makeS() { return S(); } void main() { writeln("before"); with (makeS()) { writeln("inside"); } writeln("after"); } ------------------------------------------- This program currently prints: before ~this() inside after This indicates that the S temporary inside the "with" block is already destroyed (and no copy is made). Fixing this would allow using "with" together with scope statements, as proposed here: http://forum.dlang.org/post/[email protected]
Comment #1 by andrei — 2013-10-25T08:03:38Z
Thanks for submitting this. Upvoted!
Comment #2 by code — 2013-10-25T09:57:03Z
*** This issue has been marked as a duplicate of issue 8269 ***