www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12256] New: Neither arrays nor associative arrays finalize their data

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

           Summary: Neither arrays nor associative arrays finalize their
                    data
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: rswhite4 googlemail.com



I expect this is an known issue but we may should fix this:
----
import std.stdio;

struct Foo {
    this(this) {
        writeln("Copy");
    }

    ~this() {
        writeln("DTor");
    }
}

void main() {
    Foo[] fs;
    fs ~= Foo();

    Foo[int] fas;
    fas[42] = Foo();

    // Even this doesn't change anything
    //destroy(fas);
    //destroy(fs);
}
----

You will never see "DTor". But if you work with ref count or C memory you would
hope and expect that your data is finalized. So, the compiler should finalize
the data if they is collected. Unfortunately I expect that we need a precise GC
for that? IMO the current behaviour is unexpected and bug prone.
As _workaround_ it would be helpful if destroy would work that way, but
currently it doesn't.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 25 2014
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12256


safety0ff.bugz <safety0ff.bugz gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |safety0ff.bugz gmail.com



16:03:57 PST ---


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 25 2014