Preventing nested struct destructor accessing stack frame

ag0aep6g anonymous at example.com
Tue Dec 20 06:31:09 UTC 2022


On 16.12.22 14:07, Nick Treleaven wrote:
> This seems to work:
> 
>          ~this() @trusted { if (&i > cast(void*)1024) i++; }
> 
> It would be better if there was a struct property to get the context 
> pointer though.

A quick test suggests that the context pointer is the last item in 
`tupleof`. So this might do the trick:

     ~this() { if (this.tupleof[$ - 1] !is null) i++; }

I don't know if it's guaranteed to work though. Might be an 
implementation detail.


More information about the Digitalmars-d-learn mailing list