Enhancements can enable memory-safe reference counting

tsbockman thomas.bockman at gmail.com
Wed May 26 22:06:27 UTC 2021


On Wednesday, 26 May 2021 at 21:48:40 UTC, Paul Backus wrote:
> On Wednesday, 26 May 2021 at 18:53:21 UTC, vitoroak wrote:
>> Every time I tried to do something similar in D I stumbled 
>> across the same problems and as far as I know it's not 
>> possible to implement it completely @safe today. I think one 
>> of the problems is that you can manually destroy/move any 
>> struct while there are still references/pointers to it or its 
>> internals like in the example below (I used your borrow mixin 
>> template).
>
> In theory, these examples are fine, since they result in a null 
> dereference,

No. That's what I thought at first, too, but if you walk through 
the code more carefully you will see that `x1` never gets set to 
`null`, and still points to the old target of `u1`. So, he is 
correct.

I've opened [issue 
#21981](https://issues.dlang.org/show_bug.cgi?id=21981) 
requesting a fix.


More information about the Digitalmars-d mailing list