D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4442 - Destructors not called for new-allocated struct objects
Summary: Destructors not called for new-allocated struct objects
Status: RESOLVED DUPLICATE of issue 2834
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-09 20:20 UTC by Andrei Alexandrescu
Modified: 2015-06-09 05:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2010-07-09 20:20:39 UTC
Example brought up by Sean Kelly in private correspondence:

struct S1{ ~this() { writeln("dtor"); } }
void main() {
    auto a = S1();
    auto b = new S1();
    delete b;
    auto c  = new S1();
    c = null;
    GC.collect();
}

"dtor" is only printed twice.
Comment 1 Rob Jacques 2010-07-09 23:20:00 UTC

*** This issue has been marked as a duplicate of issue 2834 ***