ref is unsafe
Rob T
rob at ucora.com
Mon Dec 31 15:39:34 PST 2012
On Monday, 31 December 2012 at 21:25:53 UTC, Mehrdad wrote:
> I don't understand why there is a discussion on trying to
> special-case ref parameters. There's nothing special about ref
> parameters... what's special is ref _returns_.
>
>
> Therefore all we need to do is disallow ref returns in @safe
> code.
Yes, but that will render a whole lot of perfectly safe code,
including easily provable safe code, from being marked as safe.
The real problem is the ability to return a temp as a ref by
obfuscating the temp from the compiler through an intermediate
wrapper of some kind.
Perhaps what must be disallowed (as being @safe) are ref returns
where the return result cannot be proven to be safe from within
the calling function, i.e. the wrapper may be safe, but the usage
of the wrapper cannot be guaranteed to be safe when used as a ref
return.
--rt
More information about the Digitalmars-d
mailing list