Thread overview
[Issue 15952] struct in closure is destroyed when parent function returns
Apr 05, 2021
Paul Backus
Apr 06, 2021
Imperatorn
[Issue 15952] [REG 2.053] struct in closure is destroyed when parent function returns
May 18, 2021
Paul Backus
Dec 29, 2022
Iain Buclaw
Dec 29, 2022
Iain Buclaw
April 05, 2021
https://issues.dlang.org/show_bug.cgi?id=15952

Paul Backus <snarwin+bugzilla@gmail.com> changed:

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

--- Comment #1 from Paul Backus <snarwin+bugzilla@gmail.com> ---
*** Issue 21669 has been marked as a duplicate of this issue. ***

--
April 06, 2021
https://issues.dlang.org/show_bug.cgi?id=15952

Imperatorn <johan_forsberg_86@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johan_forsberg_86@hotmail.c
                   |                            |om

--- Comment #2 from Imperatorn <johan_forsberg_86@hotmail.com> ---
Five year anniversary?

--
April 06, 2021
https://issues.dlang.org/show_bug.cgi?id=15952

--- Comment #3 from Steven Schveighoffer <schveiguy@gmail.com> ---
As my issue got marked as a duplicate of this, I'd say the title and expectation is different from mine.

It would be a noble goal for the compiler to try and make this work, but I think the correct path is to disallow this delegate. Prior to 2.053, this was an error because the destructor would render the instance invalid. I think we should revert to that expectation -- a struct reference shnould not outlive its lifetime.

--
May 18, 2021
https://issues.dlang.org/show_bug.cgi?id=15952

Paul Backus <snarwin+bugzilla@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |snarwin+bugzilla@gmail.com
            Summary|struct in closure is        |[REG 2.053] struct in
                   |destroyed when parent       |closure is destroyed when
                   |function returns            |parent function returns
           Severity|normal                      |regression

--
December 29, 2022
https://issues.dlang.org/show_bug.cgi?id=15952

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #4 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Steven Schveighoffer from comment #3)
> As my issue got marked as a duplicate of this, I'd say the title and expectation is different from mine.
> 

In both cases, there's a delegate function that references a field of the struct being destructor'd.  Just two different ways to exit a scope to trigger the dtor call.

--
December 29, 2022
https://issues.dlang.org/show_bug.cgi?id=15952

--- Comment #5 from Iain Buclaw <ibuclaw@gdcproject.org> ---
https://github.com/dlang/dmd/commit/931100137ee60f5d269f6c0bcf2ae34d188d54db

--