www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Bug 70] New: dtor / destructor not called for (rvalue) struct used

http://bugzilla.gdcproject.org/show_bug.cgi?id=70

             Bug #: 70
           Summary: dtor / destructor not called for (rvalue) struct used
                    in opApply
    Classification: Unclassified
           Product: GDC
           Version: development
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gdc
        AssignedTo: ibuclaw gdcproject.org
        ReportedBy: Marco.Leise gmx.de


This code:

--- 8< ---------------

import core.stdc.stdio;

struct DestroyMe
{
    ~this() { printf("~this() called\n"); }

    int opApply(in int delegate(int item) dg)
    {
        throw new Exception("Here we go!");
    }
}

void main()
{
    printf("Version with no dtor call:\n");
    try {
        foreach (item; DestroyMe()) {}
    } catch {}
    printf("Version with dtor call:\n");
    try {
        auto lvalue = DestroyMe();
        foreach (item; lvalue) {}
    } catch {}
}

--- >8 --------------

prints:
Version with no dtor call:
Version with dtor call:
~this() called

The bug is reproducable with GDC and LDC.

-- 
Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
Jul 08 2013