Enhancements can enable memory-safe reference counting
tsbockman
thomas.bockman at gmail.com
Fri May 28 00:14:15 UTC 2021
On Thursday, 27 May 2021 at 22:34:53 UTC, IGotD- wrote:
> On Thursday, 27 May 2021 at 22:13:30 UTC, tsbockman wrote:
>>
>> As Paul Backus said earlier, dereferencing a `null` pointer is
>> formally considered to be memory-safe in D. This is because it
>> will (with some rare exceptions) crash the program
>> immediately, rather than corrupting memory and continuing
>> execution with undefined behavior.
>
> That's "memory-safe" in any language in that case because
> that's a function of the operating system rather than the
> language. However, there are exception like if you are
> dereferencing a null pointer + offset and the offset is large,
> then you can corrupt memory. This is more rare though.
True. I'm neither defending nor criticizing D's definition of
"memory safe" here.
My goal is to achieve a similar level of safety and convenience
with RC and borrowing to what D currently considers `@safe` with
GC. `@safe` doesn't try to prevent `null` dereferences in GC
code, so it shouldn't be a requirement for RC code, either.
More information about the Digitalmars-d
mailing list