On 6/15/16 6:32 AM, Nick Treleaven wrote:
Hi,
Walter's made a fix for arr[$..$].ptr being unsafe to dereference - .ptr
will be @system:
https://github.com/dlang/dmd/pull/5860

A referenced druntime pull mentioned having a safe wrapper for ..ptr
that allows comparison of the pointer value, but does not allow
dereference. The wrapper would return uintptr_t (an integer guaranteed
to be big enough to hold a pointer value).

My question is: would returning void* instead really be unsafe, i.e. is
there a way of dereferencing it in safe code? (I'm not thinking about
holes in @safe, but ways by design).

Yes. If the meaning of this expression is different in @safe vs. @system, then compiler inference can affect code drastically:

auto d = arr1.ptr - arr2.ptr;

The PR I think you are referring to is mine: https://github.com/dlang/druntime/pull/1592

And this would be able to solve the problem, but I don't know if it's ready for prime time (proposed to be in core.internal).

-Steve

Reply via email to