On 2011-08-14 16:55:08 +0000, dsimcha <[email protected]> said:
Right, but they can be proven safe if they pass locals by ref **to
@safe functions**. I don't think there's any disagreement that @safe
functions shouldn't be allowed to take the address of locals or
parameters.
Actually, no, that's not safe by itself. Consider this:
ref int foo(ref int a) @safe
{
return a;
}
ref int bar() @safe
{
int a;
return foo(a);
}
And now 'bar' returns its local variable 'a' by ref, thanks to the
complicity of 'foo'. All this unsafety is perfectly @safe.
I think a @safe function shouldn't be allowed to return by ref one of
its parameter.
--
Michel Fortin
[email protected]
http://michelf.com/