Jump to page: 1 2 3
Thread overview
[Issue 13586] Destructors not run when argument list evaluation throws
Oct 08, 2014
Sobirari Muhomori
Oct 09, 2014
Walter Bright
Oct 09, 2014
Walter Bright
Oct 14, 2014
Walter Bright
Oct 14, 2014
Walter Bright
Oct 19, 2014
Walter Bright
Oct 19, 2014
Sobirari Muhomori
Oct 20, 2014
Walter Bright
Oct 26, 2014
Sobirari Muhomori
Oct 27, 2014
Sobirari Muhomori
Oct 28, 2014
Sobirari Muhomori
Nov 14, 2014
Sobirari Muhomori
Nov 17, 2014
Sobirari Muhomori
October 08, 2014
https://issues.dlang.org/show_bug.cgi?id=13586

--- Comment #1 from Sobirari Muhomori <dfj1esp02@sneakemail.com> ---
Shouldn't the argument be destructed by the caller when the callee returns? So it couldn't be constructed in place anyway.

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

monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra@gmail.com

--- Comment #2 from monarchdodra@gmail.com ---
(In reply to Walter Bright from comment #0)
> The fix is similar to what Kenji did to ensure left to right order of evaluation of arguments. If any arguments have destructors, then the argument list has to be constructed before attempting to put the argument list on the stack, because destructing them on a partially built stack is problematic. The arguments are then blitted to the stack, because the blit operation cannot throw.

It's also similar to what "opAssign implemented in terms of postblit" does. Speaking of which, in both cases, if all the arguments can be evaluated in nothrow context, then it should be OK to build the arguments in place directly.

Aren't you worried that we'll take a general performance hit building the arguments and then moving them every time we make a call?

Hows does C++ deal with this?

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

--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to Sobirari Muhomori from comment #1)
> Shouldn't the argument be destructed by the caller when the callee returns?

Yes. Once the function gets called, it gets marked by the compiler as "don't destroy this".

> So it couldn't be constructed in place anyway.

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

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to monarchdodra from comment #2)
> Aren't you worried that we'll take a general performance hit building the arguments and then moving them every time we make a call?

1. first make it work, then optimize

2. it'll only happen with structs with destructors, so (hopefully) it will be
less common


> Hows does C++ deal with this?

I imagine it's very compiler dependent - there are many ways to do it. I haven't checked. Why not give it a try? :-)

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

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com

--- Comment #5 from Andrei Alexandrescu <andrei@erdani.com> ---
(In reply to Walter Bright from comment #3)
> (In reply to Sobirari Muhomori from comment #1)
> > Shouldn't the argument be destructed by the caller when the callee returns?
> 
> Yes. Once the function gets called, it gets marked by the compiler as "don't destroy this".

Wait, I'm confused. On the normal path (no exceptions) isn't the callee destroying its by-value arguments?

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

--- Comment #6 from monarchdodra@gmail.com ---
(In reply to Andrei Alexandrescu from comment #5)
> (In reply to Walter Bright from comment #3)
> > (In reply to Sobirari Muhomori from comment #1)
> > > Shouldn't the argument be destructed by the caller when the callee returns?
> > 
> > Yes. Once the function gets called, it gets marked by the compiler as "don't destroy this".
> 
> Wait, I'm confused. On the normal path (no exceptions) isn't the callee destroying its by-value arguments?

I think Walter missunderstood the question, as his answer seems to mean what you just said (the opposite of the original question).

Walter?

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

--- Comment #7 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to Andrei Alexandrescu from comment #5)
> (In reply to Walter Bright from comment #3)
> > (In reply to Sobirari Muhomori from comment #1)
> > > Shouldn't the argument be destructed by the caller when the callee returns?
> > 
> > Yes. Once the function gets called, it gets marked by the compiler as "don't destroy this".
> 
> Wait, I'm confused. On the normal path (no exceptions) isn't the callee destroying its by-value arguments?

Yes. If the function doesn't get called, then the caller has to call the destructors on the partially constructed argument list. If the function does get called, then the function destroys the arguments.

Hence having the compiler mark it to be careful where the destructor code gets placed.

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

--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> ---
(This is one of the complications that make ref counting not so performant.)

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

--- Comment #9 from Andrei Alexandrescu <andrei@erdani.com> ---
Thanks!

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

--- Comment #11 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to Sobirari Muhomori from comment #10)
> (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?

Because the caller can transfer ownership to the callee. If the callee never destructed its parameters, this could not be done.

--
« First   ‹ Prev
1 2 3