ref is unsafe

jerro a at a.com
Sun Dec 30 14:18:43 PST 2012


> Honestly though, I'm inclined to argue that functions which 
> return by ref and
> have a ref parameter of that same type just be considered 
> @system.

What about this:

struct Foo
{
     int a;
}

ref int bar(ref Foo foo)
{
     return foo.a;
}

the parameter type and the return type here are different, but 
bar still returns a reference to its parameter. I guess you 
should consider all functions that return ref and have at least 
one ref parameter @system (unless they are marked @trusted).


More information about the Digitalmars-d mailing list