Escape analysis

Don nospam at nospam.com.au
Wed Oct 29 02:54:45 PDT 2008


Walter Bright wrote:
> Sean Kelly wrote:
>> How does the compiler handle this?  It can't tell by inspecting the 
>> type whether the data for S is dynamic... in fact, the same could be 
>> said of a "scope" instance of a class.  I guess it would have to 
>> assume that object variables without a "noscope" label must be scoped?
> 
> What you're talking about is the escaping of pointers to local 
> variables. The compiler does not detect it, except in trivial cases.
> 
> This is why, in safe mode, taking the address of a local variable will 
> not be allowed.

You could allow it in inside a pure function, whenever the return type 
does not contain pointers.



More information about the Digitalmars-d mailing list