www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10623] New: destructor not called for function argument if constructing another argument throws

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10623

           Summary: destructor not called for function argument if
                    constructing another argument throws
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrei erdani.com


--- Comment #0 from Andrei Alexandrescu <andrei erdani.com> 2013-07-12 08:52:50
PDT ---
Consider:

import std.stdio;

struct S1 { 
    this(int) { writeln("constructed"); } 
    ~this() { writeln("destroyed"); } 
}
struct S2 { this(int) { throw new Exception("a"); } }

void fun(S1, S2, S1) {}

void main()
{
    fun(S1(2), S2(2), S1(2));
}

Running this code will create an object of type S1 that is never destroyed.
This is somewhat related to http://d.puremagic.com/issues/show_bug.cgi?id=9704,
just there's no postblit.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 12 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10623


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru


--- Comment #1 from Maxim Fomin <maxim maxim-fomin.ru> 2013-07-12 09:08:36 PDT
---
I think this can be marked as a dup because it is a particular situation of
essentially the same case described in issue 9704.

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


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |monarchdodra gmail.com
           See Also|                            |http://d.puremagic.com/issu
                   |                            |es/show_bug.cgi?id=9704
         Resolution|                            |DUPLICATE


--- Comment #2 from monarchdodra gmail.com 2013-07-12 11:05:06 PDT ---
(In reply to comment #1)
 I think this can be marked as a dup because it is a particular situation of
 essentially the same case described in issue 9704.
This indeed a more generically worded description, but essentially, the same thing. Also, (since links never hurt), this issue was also discussed recently in learn: http://forum.dlang.org/thread/20130628005448.00000969 unknown?page=2 *** This issue has been marked as a duplicate of issue 9704 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 12 2013