Preventing nested struct destructor accessing stack frame
j
my.email at gmail.com
Sun Dec 18 22:06:28 UTC 2022
On Friday, 16 December 2022 at 12:17:40 UTC, Nick Treleaven wrote:
> This code segfaults when the GC calls the dtor after the
> unittest succeeds:
>
> ```d
> unittest
> {
> int i;
> struct S
> {
> ~this() { i++; }
> }
> (*new S).destroy;
> }
> ```
>
> It seems destroy clears the context pointer. Is there a way to
> test if the context pointer is null in the dtor, to prevent the
> increment?
What is a context pointer? You want to check if i is valid after
destroy has been called but from within the destructor and after
the unittest returns?
More information about the Digitalmars-d-learn
mailing list