On Thursday, 5 June 2014 at 19:57:08 UTC, Steven Schveighoffer wrote:
A possible fix could be to reject the call to ptr at runtime if the slice is empty.

I don't know why you'd ever do "arr.ptr" in the first place, other than to avoid the bounds check. So I think the call should just be unsafe, and we call it a day. Or maybe to interface with a function that want a pointer?

"Maybe", we could get away with allowing "&arr[someIndex]" though. The compiler would have to be able to "understand" this is not escaping a reference (for *DYNAMIC* arrays anyways).

Reply via email to