digitalmars.D.bugs - [Issue 7516] New: Postblit not called for structs returned from a ternary operator
- d-bugmail puremagic.com (60/60) Feb 16 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7516
- d-bugmail puremagic.com (10/10) Apr 20 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7516
- d-bugmail puremagic.com (6/6) Apr 20 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7516
- d-bugmail puremagic.com (44/44) May 10 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7516
- d-bugmail puremagic.com (10/10) May 10 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7516
http://d.puremagic.com/issues/show_bug.cgi?id=7516 Summary: Postblit not called for structs returned from a ternary operator Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: wrong-code Severity: major Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: sludwig outerproduct.org --- Comment #0 from Sönke Ludwig <sludwig outerproduct.org> 2012-02-16 03:28:54 PST --- Created an attachment (id=1075) Reproduction case Attached is a small example with a pseudo RefCount struct. Running with the ternary operator enabled "dmd -version=BUG -run" yields: --- 1st pass POS1: 613D80 -100 CREATE 18FDFC 1 DESTROY 18FDE0 -100 IN DESTROY 18FDE0 -100 OUT POS2: 613D80 1 DESTROY 18FE0C 1 IN <- destroys the object although the static variable DESTROY 18FE0C -100 OUT in func() should still hold a reference 2nd pass POS1: 613D80 0 <- the static variable now references a destroyed POS2: 613D80 0 object DESTROY 18FE0C 0 IN DESTROY 18FE0C -1 OUT --- The line "return cnt.cnt ? cnt : cnt;" fails to call the struct's postblit and causes the returned object to get destroyed. running with "dmd -run" yields the expected output: --- 1st pass POS1: 533D80 -100 CREATE 18FDFC 1 DESTROY 18FDE0 -100 IN DESTROY 18FDE0 -100 OUT POS2: 533D80 1 COPY 18FE0C 2 <- correctly copied on return DESTROY 18FE0C 2 IN DESTROY 18FE0C 1 OUT 2nd pass POS1: 533D80 1 POS2: 533D80 1 COPY 18FE0C 2 DESTROY 18FE0C 2 IN DESTROY 18FE0C 1 OUT <- the static reference is still there --- "return cnt;" will correctly call the postblit constructor. Occurs for DMD 2.058 (2.57 fails for both cases) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 16 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7516 SomeDude <lovelydear mailmetrash.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lovelydear mailmetrash.com --- Comment #1 from SomeDude <lovelydear mailmetrash.com> 2012-04-20 00:43:05 PDT --- See also issue 7506 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 20 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7516 --- Comment #2 from SomeDude <lovelydear mailmetrash.com> 2012-04-20 01:01:16 PDT --- See also issue 7530 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 20 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7516 --- Comment #3 from Kenji Hara <k.hara.pg gmail.com> 2012-05-10 22:56:59 PDT --- Test cases: void main() { static struct S { int val; this(int n) { val = n; } this(this) { val *= 3; } } // cond ? lvalue : lvalue S foo(bool f) { auto s1 = S(1), s2 = S(2); return f ? s1 : s2; } auto s1 = foo(true); assert(s1.val == 3); auto s2 = foo(false); assert(s2.val == 6); // cond ? rvalue : rvalue S bar(bool f) { return f ? S(1) : S(2); } auto s3 = bar(true); assert(s3.val == 1); auto s4 = bar(false); assert(s4.val == 2); // cond ? lvalue : rvalue S baz(bool f) { auto s1 = S(1); return f ? s1 : S(2); } auto s5 = baz(true); assert(s5.val == 3); auto s6 = baz(false); assert(s6.val == 2); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 10 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7516 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dsimcha yahoo.com --- Comment #4 from Kenji Hara <k.hara.pg gmail.com> 2012-05-10 23:05:16 PDT --- *** Issue 7130 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 10 2012