HOSOKAWA Kenchi wrote:
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* ap()
{
scope auto a = new int[1];
return a.ptr; // no error; this is the problem
}
Probably should be an error, but, FWIW, scope arrays are still
heap-allocated (yeah, I know it's inconsistent). So there's no chance of
memory corruption, etc.; it's as if you didn't have the "scope" there.