October 19, 2014
https://issues.dlang.org/show_bug.cgi?id=13586

--- Comment #10 from Sobirari Muhomori <dfj1esp02@sneakemail.com> ---
(In reply to Andrei Alexandrescu from comment #5)
> Wait, I'm confused. On the normal path (no exceptions) isn't the callee destroying its by-value arguments?

Huh? Why not caller?

--
October 20, 2014
https://issues.dlang.org/show_bug.cgi?id=13586

--- Comment #12 from Walter Bright <bugzilla@digitalmars.com> ---
https://github.com/D-Programming-Language/dmd/pull/4078

--
October 26, 2014
https://issues.dlang.org/show_bug.cgi?id=13586

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
October 26, 2014
https://issues.dlang.org/show_bug.cgi?id=13586

--- Comment #13 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/aea25d6b6ea8383058f4987fe11ae16bbda18852 fix Issue 13586 - Destructors not run when argument list evaluation throws

https://github.com/D-Programming-Language/dmd/commit/11276b83f93a301a7d258e72bf8cea6a504d28b7 Merge pull request #4078 from WalterBright/fix13586

fix Issue 13586 - Destructors not run when argument list evaluation throws

--
October 26, 2014
https://issues.dlang.org/show_bug.cgi?id=13586

--- Comment #14 from Sobirari Muhomori <dfj1esp02@sneakemail.com> ---
(In reply to Walter Bright from comment #11)
> Because the caller can transfer ownership to the callee. If the callee never destructed its parameters, this could not be done.

If transfer of ownership makes things messy, it's better to not do that. Is there a reason, why the caller can't keep ownership to itself?

--
October 26, 2014
https://issues.dlang.org/show_bug.cgi?id=13586

--- Comment #15 from monarchdodra@gmail.com ---
(In reply to Sobirari Muhomori from comment #14)
> (In reply to Walter Bright from comment #11)
> > Because the caller can transfer ownership to the callee. If the callee never destructed its parameters, this could not be done.
> 
> If transfer of ownership makes things messy, it's better to not do that. Is there a reason, why the caller can't keep ownership to itself?

I could be talking out of my ass, but I'd *assume* ownership transfer is required for proper move semantics. The easiest way to move an object from scope A to scope B would be for A to "give ownership" to B.

EG:

foo(getLValue());

Here the outerscope calls neither postblit nor destructor.

Speaking of which: Walter, is there anything blocking https://issues.dlang.org/show_bug.cgi?id=12684 ?

Or has it simply not been brought to DMD team's attention?

--
October 27, 2014
https://issues.dlang.org/show_bug.cgi?id=13586

--- Comment #16 from Sobirari Muhomori <dfj1esp02@sneakemail.com> ---
(In reply to monarchdodra from comment #15)
> I could be talking out of my ass, but I'd *assume* ownership transfer is required for proper move semantics.

AFAIK, move semantics is need only for return values, not for arguments.

> foo(getLValue());
> 
> Here the outerscope calls neither postblit nor destructor.

A proposed solution to this issue is to place arguments on the caller's stack, so that's where they're moved, not to the callee's stack.

--
October 27, 2014
https://issues.dlang.org/show_bug.cgi?id=13586

--- Comment #17 from Andrei Alexandrescu <andrei@erdani.com> ---
(In reply to Sobirari Muhomori from comment #16)
> (In reply to monarchdodra from comment #15)
> > I could be talking out of my ass, but I'd *assume* ownership transfer is required for proper move semantics.
> 
> AFAIK, move semantics is need only for return values, not for arguments.

Passing ownership into the callee is needed everywhere the callee gets an rvalue and then e.g. forwards it along. It's a great optimization that simplifies D code compared to C++ code, which is always burdened with cleaning up objects at the caller level.

--
October 28, 2014
https://issues.dlang.org/show_bug.cgi?id=13586

--- Comment #18 from Sobirari Muhomori <dfj1esp02@sneakemail.com> ---
What optimization does it provide? Most parameters are scoped, i.e. not owned by the callee, so since they are owned by the caller, they are destroyed by the caller.

--
November 14, 2014
https://issues.dlang.org/show_bug.cgi?id=13586

Sobirari Muhomori <dfj1esp02@sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=12684

--- Comment #19 from Sobirari Muhomori <dfj1esp02@sneakemail.com> ---
If the caller owns the arguments, it can also help with issue 12684 and similar.

--