www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6199] New: [GSoC] Postblit not called when returning a reference to a by-value function.

reply d-bugmail puremagic.com writes:
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



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: -------
Jun 23 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6199


SomeDude <lovelydear mailmetrash.com> changed:

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



PDT ---
Bug is confirmed with 2.059

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 24 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6199




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 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6199




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


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 07 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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 07 2012
prev sibling parent d-bugmail puremagic.com writes:
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



*** 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: -------
May 10 2012