Program crash: GC destroys an object unexpectedly
Steven Schveighoffer
schveiguy at gmail.com
Thu Sep 23 12:53:14 UTC 2021
On 9/23/21 3:27 AM, eugene wrote:
> On Wednesday, 22 September 2021 at 18:38:34 UTC, Steven Schveighoffer
> wrote:
>> Your experience is not typical though (clearly, as many of us
>> long-time D users had no idea why it was happening).
>
> Oh, yeah - I have special trait of bumping against
> various low probability things :)
>
>> But for sure if this turns you off, I can understand how it can be too
>> frustrating to learn the new rules.
>
> 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. We need to add a better way to do that
(similar to C# KeepAlive). I made an
[attempt](https://code.dlang.org/packages/keepalive), but I think it's
not guaranteed to work, I've already found ways to prove it fails.
-Steve
More information about the Digitalmars-d-learn
mailing list