Allocator-aware @safe reference counting is still not possible
Dukc
ajieskola at gmail.com
Sun Sep 25 15:07:04 UTC 2022
On Sunday, 25 September 2022 at 14:52:09 UTC, Paul Backus wrote:
> On Sunday, 25 September 2022 at 14:45:38 UTC, Dukc wrote:
>> 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.
>
> Well, of course, if you are willing to write unsound `@trusted`
> code, anything can be made `@safe`. :)
The `SafeRefCounted` destructor wouldn't be any less sound that
it's now. If `free` did something it's not supposed to, the
`@trusted` attribute on the destructor would be invalid. It isn't
any different with a custom deallocator.
More information about the Digitalmars-d
mailing list