I am learning c++ using tutorials from http://www.learncpp.com. In the lesson on Dynamic memory allocation with new and delete (http://www.learncpp.com/cpp-tutorial/69-dynamic-memory-allocation-with-new-and-delete/), it states:
Similarly, when a dynamically allocated variable is deleted, the pointer pointing to it is not zero’d. Consider the following snippet:
int *pnValue = new int;
delete pnValue; // pnValue not set to 0
if (pnValue)
*pnValue = 5; // will cause a crash
However, when I try it (compiler: GNU GCC compiler, ubuntu), my program doesn't crash.
int *pnValue = new int;
delete pnValue; // pnValue not set to 0
if (pnValue)
*pnValue = 5; // will cause a crash -> doesn't
std::cout << "Did not crash" << std::endl;
What is happening here? Is there any form of runtime checking in C++?