On Wed, Mar 5, 2014 at 11:42 PM, Patrick Walton <[email protected]> wrote: > Dereference of a null pointer is memory-unsafe due to being undefined > behavior. You can't count on dereference of nullptr resulting in a load of > address zero: the optimizer is free to (and often does) remove that load and > any code following it. This means that, for example, clang will cheerfully > allow you to fall off the end of a function after dereferencing a moved > pointer.
True. I have never seen this in a real program (and if I try to test it by moving a unique_ptr and then dereferencing it, clang generates a ud2, although it does not for just dereferencing 0), but it is possible. Still, I don't think most C++ programmers would consider it a big deal. _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
