On Mon, Mar 3, 2014 at 11:44 PM, Nathan Myers <n...@cantrip.org> wrote: > C++ does allow a reference to last longer than the > referent, and that's worth calling attention to.
Yeah... for memory safety I would consider a reference the same thing as a pointer, although it helps in other cases such as null pointers and forgotten initialization. Admittedly, it's also my guess that most actual use-after-free vulnerabilities and bugs in C++ come from raw pointers in fields rather than function arguments, things like cyclic pointers and supposedly long-lived objects. However, even with function arguments, there is a difference between "probably not unsafe" and "guaranteed to be safe". Also, borrowed pointers can sometimes be used in those cases in fields, although it's my impression - possibly wrong, since I still haven't written that much Rust code - that this can be difficult. Incidentally, to the extent this is about a proposed document comparing Rust's safety to C++ in general, there are other things than ownership that should be mentioned. Multithreading is a big one, if also a tradeoff with convenience. _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev