digitalmars.D.bugs - [Issue 6203] New: [GSoC] RefCounted (and clear()) doesn't call destructors of members of structs.
- d-bugmail puremagic.com (55/55) Jun 23 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6203
- d-bugmail puremagic.com (12/12) Jul 19 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6203
http://d.puremagic.com/issues/show_bug.cgi?id=6203 Summary: [GSoC] RefCounted (and clear()) doesn't call destructors of members of structs. Product: D Version: D1 & D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: cristi.cobzarenco gmail.com --- Comment #0 from Cristi Cobzarenco <cristi.cobzarenco gmail.com> 2011-06-23 15:57:31 PDT --- Code: import std.typecons; import std.stdio; struct Enclosing { Member m; ~this() { writeln("Enclosing.~this()"); } } struct Member { ~this() { writeln("Member.~this()"); } } alias RefCounted!Enclosing Test; int main() { Test a; a.RefCounted.initialize(); return 0; } Outputs: Enclosing.~this() Member.~this() Enclosing.~this() The first two destructor calls are because of the call to initialize() which replaces the internal copy. The third one is called when 'a' goes out of scope. Unfortunately the destructor of 'a.m' is not called. This seems to be because of clear(): Code: int main() { Enclosing a; clear(a); return 0; } Output: Enclosing.~this() Enclosing.~this() Member.~this() The last two calls are when 'a' goes out of scope. The first one is on clear(), but as you can see it only calls the destructor of Enclosing. This causes memory leaks in my project, but that's about it. So it's not a blocker, but it's important for it to get fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 23 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6203 Cristi Cobzarenco <cristi.cobzarenco gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE --- Comment #1 from Cristi Cobzarenco <cristi.cobzarenco gmail.com> 2011-07-19 06:28:06 PDT --- The cause is the same as in Issue 5667. *** This issue has been marked as a duplicate of issue 5667 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 19 2011