Program crash: GC destroys an object unexpectedly

eugene dee0xeed at gmail.com
Thu Sep 23 13:18:10 UTC 2021


On Thursday, 23 September 2021 at 12:53:14 UTC, Steven 
Schveighoffer wrote:
>> Show me these rules!
>
> They are here: 
> https://dlang.org/spec/interfaceToC.html#storage_allocation
>
> With the caveat, of course, that the recommendation to "leave a 
> pointer on the stack" is not as easy to follow as one might 
> think with the optimizer fighting against that.

Yes, as you explained me, the root of the
problem in my examples were dead store elimination.

> We need to add a better way to do that (similar to C# 
> KeepAlive).

Do you mean some function attribute?..



More information about the Digitalmars-d-learn mailing list