Enhancements can enable memory-safe reference counting
vitoroak
carvalhogvm at gmail.com
Thu May 27 00:20:44 UTC 2021
On Thursday, 27 May 2021 at 00:05:24 UTC, Paul Backus wrote:
> On Wednesday, 26 May 2021 at 22:06:27 UTC, tsbockman wrote:
>> 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:
>>>
>>> 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.
>
> Thanks, I see the problem now.
>
> I guess the conclusion we're forced to come to is that, given
> current language rules, it is incorrect to mark the destructor
> as `@trusted`.
Yeah, my point is that if there's any way to make this @safe. The
same happens for a Vector implementation where you can call push
(that can reallocate) while having a reference to an element.
I also don't know a simple way to solve this problem but I think
it's important if we want to sell D to have @nogc data structures.
More information about the Digitalmars-d
mailing list