I am planning to submit a PR changing this so that we have no need of
zeroing memory out. This does mean that some programs which today are
legal will become illegal, because the compiler must know
unambiguously at each point what is to be freed: in other words, if
one path of an if/else consumes a variable, the other path must too
(at least if those paths rejoin). This patch isn't really underway yet
(though I've been working on some of the necessary prerequisites) and
I plan to writeup a more formal description once I get started hacking
on it. If nothing else, I hope to modify the moves analysis soon to
impose the necessary requirements so that code will be backwards
compatible, even if we continue to use zeroing at runtime for a while.


Niko

On Sat, Nov 16, 2013 at 07:03:22PM +0100, Benjamin Herr wrote:
> Hi,
> 
> as I understand it, currently, rust zeros variables after cleanup or
> when moved from (and adds a "drop flag" field to structs with cleanup
> logic to be zeroed), and so dynamically, at runtime, tracks which
> variables need to be freed/have destructors called.
> 
> This might change somewhat: https://github.com/mozilla/rust/issues/5016
> 
> -benh
> 
> On Sat, 2013-11-16 at 17:59 +0100, spir wrote:
> > Hello,
> > 
> > say a function defines 4 pointed elements of data. Depending on logical 
> > conditions, one of them escapes the func to be assigned to some world 
> > variable 
> > (static or on heap), while another is returned. How does Rust determine 
> > which of 
> > those data are to be freed? Seems this can only be done dynamically, at 
> > runtime, 
> > or do I miss a relevant point? Is there a cheap algo to do this?
> > (Also, those elements of data can be arbitrarily complex, and hold other 
> > pointed 
> > data which themselves may be placed there conditionally.)
> > 
> > Thank you,
> > denis
> > 
> > _______________________________________________
> > Rust-dev mailing list
> > Rust-dev@mozilla.org
> > https://mail.mozilla.org/listinfo/rust-dev
> 
> 
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to