On Wednesday, September 20, 2017 08:33:34 Nordlöw via Digitalmars-d wrote: > On Wednesday, 20 September 2017 at 07:38:00 UTC, Jonathan M Davis > > wrote: > > T[n] s(T, size_t n)(auto ref T[n] array) pure nothrow @nogc > > @safe > > { > > > > return array; > > > > } > > What about adding `s` to std.array in the meanwhile? I wonder > what Walter says about the static array to slice assignment. > Isn't it memory-safe?
If you use auto with the return value, you're fine, because you get a static array, and the orignal static array is copied, but if you assign it to a dynamic array, it's not at all memory safe. It's returning a slice of an rvalue and is a clear violation of https://issues.dlang.org/show_bug.cgi?id=12625 - Jonathan M Davis