Escaping ref to stack mem sometimes allowed in @safe?

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 17 08:03:51 PDT 2016


On Friday, October 14, 2016 16:49:44 Nick Sabalausky via Digitalmars-d-learn 
wrote:
> This compiles. Is it supposed to?
>
> @safe ubyte[] foo()
> {
>   ubyte[512] buf;
>   auto slice = buf[0..$];
>   // Escaping reference to stack memory, right?
>   return slice;
> }
>
> Or is the escaping reference detection not intended to be 100%? Or
> something else I'm missing?
>
> Should I file @ bugzilla?

It's a long-standing bug:

https://issues.dlang.org/show_bug.cgi?id=8838

But Walter has been working on @safety issues recently (particularly with
regards to stuff like parameters escaping, because of DIP1000), so a fix
should finally be coming.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list