April 08, 2007

So, what's up with deleting NULL

I've always thought that a C++ program showing a behavior like:
(Of course, you won't find something like this on your code, but it points the fact)

int main()
void *v = 0;
delete v;

would make your program just die with a segmentation fault, but I just learned that it turns out to be a valid behavior, so a little program like this will compile and run with no problem.
Just Amazing ;P

(found at http://techbase.kde.org/Development/Tutorials/Common_Programming_Mistakes#NULL_pointer_issues)

No comments:

Creative Commons License All this site has a Creative Commons License.