[Issue 11351] New: Destructor of "with" statement expression result is called too soon
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 25 05:05:14 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11351
Summary: Destructor of "with" statement expression result is
called too soon
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: thecybershadow at gmail.com
--- Comment #0 from Vladimir Panteleev <thecybershadow at gmail.com> 2013-10-25 15:05:12 EEST ---
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/l4ccb4$25ul$1@digitalmars.com
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list