On Tuesday, January 24, 2017 11:28:17 Atila Neves via Digitalmars-d-learn 
wrote:
> void main() {
>      foo;
> }
>
> void foo() @safe {
>      int[] array;
>      auto ptr = array.ptr;
> }
>
>
> foo.d(7): Deprecation: array.ptr cannot be used in @safe code,
> use &array[0] instead
>
>
> &array[0] is incredibly ugly and feels like an unnecessary hack,
> and I'm wondering why it's @safe.

Likely because it does bounds checking, so you at least know that it's not
null. But I don't see why that would really improve much considering that
the odds are that you're really going to be accessing far more than just the
first element with the pointer. It seems _slightly_ better from a safety
perspective but only slightly. So, I don't know what the point is in
suggesting it as an alternative.

- Jonathan M Davis

Reply via email to