4 ms·
This is definitely outside the scope of my knowledge, but if you dereference a null pointer, won't you get an illegal memory access? Undefined behavior, at lea
by crantanplum 12y ago
This is definitely outside the scope of my knowledge, but if you dereference a null pointer, won't you get an illegal memory access?
Undefined behavior, at least colloquially, is about dereferencing a pointer to memory that may or may not be accessed and may or may not work/crash-the-program. That's what makes it undefined and an absolute disaster to track down.
I'm pretty sure that if you try to deference memory address zero the OS will bark at you.
Again, it's not my area of expertise, so please correct me if I'm wrong
- dbaupp 12y agoDereferencing null is not guaranteed to do any particular behaviour; on many systems, getting the machine to actually dereference 0 will give a segfault/illegal memory access, but the compiler optimises assuming this never happens, and so can break a program that accidentally "relies" on it. e.g. - http://stackoverflow.com/q/6793262/1256624 http://stackoverflow.com/q/6793262/1256624 - http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html http://blog.llvm.org/2011/05/what-every-c-programmer-should-...