Answer to Question dangling-6

Using a dangling pointer can lead to all kinds of crazy behavior. Officially, according to the definition of C++, if your program uses a dangling pointer, the behavior of your program from that point on is undefined. It could do anything.

From a practical standpoint, using a dangling pointer is an error that often shows up at a point in your program at a place that is remote from the place where the actual error occurs. It also tends to show up as the program doing things that you would think it could not possibly do. Such errors are very difficult to diagnose and fix.

It is important to avoid using dangling pointers. That requires discipline.