Is return by ref really @safe?

Michel Fortin michel.fortin at michelf.com
Tue Mar 9 18:52:07 PST 2010


This compiles, but should it?

@safe
ref int foo(ref int a) {
	return a;
}

@safe
ref int bar() {
	int a;
	return foo(a); // leaking reference to a beyond bar's scope
}

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list