It seems dmd 2.031 forgets scope attribute for array.ptr in some cases, so that it allows escaping a pointer to scope local array. I'm not sure this is a bug or a kind of "dangerous-but-valid".
int[] a() { scope auto a = new int[1]; return a; // error; escaping reference to scope local array } int* ap() { scope auto a = new int[1]; return a.ptr; // no error; this is the problem } int* i() { int i; return &i; // error; escaping reference to local variable } int* ip() { scope int* p = new int; return p; // no error; only is "int* p" local, "new int" not scope local? }