On Monday, 18 January 2016 at 19:32:19 UTC, bitwise wrote:
struct S;
void func(ref S s);
func(S()); // FINE
void func(ref S s) @safe;
func(S()); // ERROR
Isn't that backwards? I mean, @safe functions can't escape their
parameters, so whether or not it is a temporary shouldn't matter
to a @safe function. Meanwhile, non-@safe *can* escape
parameters, and would fail or at least lead to problems if it
tried to escape a ref to a temporary.
On the other hand, banning @safe code from passing a temporary as
a ref parameter, while allowing it in non-@safe code makes a bit
more sense to me, but seems less desirable.