Allocator-aware @safe reference counting is still not possible

Dukc ajieskola at gmail.com
Sun Sep 25 14:45:38 UTC 2022


On Sunday, 25 September 2022 at 14:23:22 UTC, Paul Backus wrote:
> On Sunday, 25 September 2022 at 14:04:31 UTC, Dukc wrote:
>> On Sunday, 25 September 2022 at 13:12:11 UTC, Paul Backus 
>> wrote:
>>>
>>> To make this work, we need the compiler to *enforce* the 
>>> rules about what the deallocator can and cannot do.
>>
>> Why? The deallocator is going to be `@system` anyway.
>
> If you have `isolated`, the deallocator can be made `@safe` by 
> having it take an `isolated` pointer as its argument.

A language change like that is ideal in the long term. My point, 
however, is that we're not blocked on waiting for one. An 
allocator-enabled safe reference counter is possible with the 
present language (except perhaps for some yet-undiscovered 
issue). The downside that the deallocators will have to be 
reviewed against not only causing UB by themselves, but also 
against leaking a pointer so that it can be reached by `@safe` 
code.




More information about the Digitalmars-d mailing list