digitalmars.D.bugs - [Issue 7541] New: Postblit not called when returning from an array of structs.
- d-bugmail puremagic.com (74/74) Feb 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7541
- d-bugmail puremagic.com (11/11) May 10 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7541
http://d.puremagic.com/issues/show_bug.cgi?id=7541 Summary: Postblit not called when returning from an array of structs. Product: D Version: D2 Platform: All OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: johnaston.dev gmail.com --- Comment #0 from John Aston <johnaston.dev gmail.com> 2012-02-19 03:20:58 PST --- import std.stdio; struct S { string m_str = "defaultString"; this(this) { writeln("In this(this)"); } ~this() { writeln("In ~this():"~m_str); } } struct Holder { S[] m_arr; S m_s; this(S[] arr) { m_arr = arr; m_s.m_str="H.m_s"; } S getSMem() { return m_s; } S getSVec() { return m_arr[0]; } S getSLocal() { S local = S("localString"); return local; } } void main() { Holder h = Holder(new S[1]); S s1 = h.getSMem(); S s2 = h.getSVec(); S s3 = h.getSLocal(); } The above in Windows D2.058 produces: In this(this) In ~this():localString In ~this():defaultString In ~this():H.m_s In ~this():H.m_s Only one postblit is produced in the above (from the getSMem() call). The getSLocal() call can just move the struct. However, getSVec() does not result in a postblit. I noticed this in the context of a reference counting struct held in a std.container.Array, and there were too few calls to this(this) compared to ~this(). This issue was discussed in: http://stackoverflow.com/questions/9344579/why-is-thisthis-not-called-when-returning-from-array-of-structs -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 19 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7541 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE --- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2012-05-10 19:38:30 PDT --- *** This issue has been marked as a duplicate of issue 7530 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 10 2012