Thread overview
[Issue 6199] New: [GSoC] Postblit not called when returning a reference to a by-value function.
Jun 23, 2011
Cristi Cobzarenco
Apr 24, 2012
SomeDude
May 05, 2012
SomeDude
May 05, 2012
Kenji Hara
May 08, 2012
Walter Bright
May 11, 2012
Kenji Hara
June 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6199

           Summary: [GSoC] Postblit not called when returning a reference
                    to a by-value function.
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: cristi.cobzarenco@gmail.com


--- Comment #0 from Cristi Cobzarenco <cristi.cobzarenco@gmail.com> 2011-06-23 11:14:10 PDT ---
Code:

import std.stdio;

struct Test {
    this( this ) { writeln( "postblit" ); }
    ~this()      { writeln( "destroyed" );    }
}

void takesVal( Test x ) {}
ref Test returnsRef( ref Test x ) { return x; }

int main() {
    Test x;
    takesVal( returnsRef( x ) );
    return 0;
}

--------------
Output:
destroyed
destroyed


So while there is copy getting destroyed, the postblit doesn't get called. The code works fine when passing a ref argument:

Code:
[...]
void f( ref Test x ) {
    takesVal( x );
}

int main() {
    Test x;
    f( x );
}
--------------
Output:
postblit
destroyed
destroyed

This bug is probably related to http://d.puremagic.com/issues/show_bug.cgi?id=5737

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6199


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #1 from SomeDude <lovelydear@mailmetrash.com> 2012-04-24 11:43:49 PDT ---
Bug is confirmed with 2.059

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 05, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6199



--- Comment #2 from SomeDude <lovelydear@mailmetrash.com> 2012-05-04 23:01:01 PDT ---
See also related issue 5737 and issue 8045

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 05, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6199


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, wrong-code
         OS/Version|Windows                     |All


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2012-05-04 23:32:00 PDT ---
https://github.com/D-Programming-Language/dmd/pull/927

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6199



--- Comment #4 from github-bugzilla@puremagic.com 2012-05-07 18:10:39 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/9c03f1445966163321cf40456f35f83f534f2b1a
fix Issue 6199 - [GSoC] Postblit not called when returning a reference to a
by-value function.

https://github.com/D-Programming-Language/dmd/commit/7f18602f38082d8b837112fed1d5d10b222e3b87 Merge pull request #927 from 9rnsr/fix_postblit

Issue 5737 & 6199 - fix postblit call with ref return

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6199


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6199


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2012-05-10 19:53:28 PDT ---
*** Issue 6257 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: -------