On 12/16/22 7:17 AM, 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?

Check if the struct is the init value?

```d
~this() { if(this !is this.init) ++i;}
```

Not ideal I guess, because really it's the context pointer you care about.

-Steve

Reply via email to