Why is &array[0] @safer than array.ptr?
Stefan Koch via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jan 24 03:30:15 PST 2017
On Tuesday, 24 January 2017 at 11:28:17 UTC, Atila Neves 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.
>
> Atila
the type is still a type with bounds and not an unbounded pointer.
More information about the Digitalmars-d-learn
mailing list