*((int*)0): In theory, this is memory unsafe; In practical, this has been
exist for about thirty years, making many software system crash. But I
know, most C++ programmers don't consider it a big deal.


2014-03-06 13:06 GMT+08:00 comex <com...@gmail.com>:

> On Wed, Mar 5, 2014 at 11:42 PM, Patrick Walton <pwal...@mozilla.com>
> 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
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>



-- 
by *Liigo*, http://blog.csdn.net/liigo/
Google+  https://plus.google.com/105597640837742873343/
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to