www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11351] New: Destructor of "with" statement expression result is called too soon

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: thecybershadow gmail.com


--- Comment #0 from Vladimir Panteleev <thecybershadow 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: -------
Oct 25 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11351


Andrei Alexandrescu <andrei erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei erdani.com


--- Comment #1 from Andrei Alexandrescu <andrei erdani.com> 2013-10-25 08:03:38
PDT ---
Thanks for submitting this. Upvoted!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 25 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11351


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |code dawg.eu
         Resolution|                            |DUPLICATE


--- Comment #2 from Martin Nowak <code dawg.eu> 2013-10-25 09:57:03 PDT ---
*** This issue has been marked as a duplicate of issue 8269 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 25 2013