http://d.puremagic.com/issues/show_bug.cgi?id=2834

           Summary: Struct Destructors are not called by the GC, but called
                    on explicit delete.
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: spec
          Severity: minor
          Priority: P3
         Component: DMD
        AssignedTo: bugzi...@digitalmars.com
        ReportedBy: sandf...@jhu.edu


According to the spec: [Struct] "Destructors are called when an object goes out
of scope. Their purpose is to free up resources owned by the struct object."
And while the heap is always 'in scope', it does delete structs which arguably
places them out of scope. Note that an explicit call to delete will run the
destructor. At a minimum, the spec should be updated to clearly reflect this
limitation. Since memory leaks, open files, etc will probably occur when a
struct with a postblit is manually allocated directly on the heap, instead of
on the stack or as part of an object, this issue might warrant a compiler
warning/error (i.e. an explicit cast is required).


-- 

Reply via email to