Zero pointer vs sagging pointer

Is there any significant difference between a null pointer and a dangling pointer? It looks like these are both terms used for pointers that don't point to anything. Is the idea that a dangling pointer is used to signify something, and now not - where the null pointer is just a pointer that does not refer to anything (no matter what it pointed to in the past)?

+4
source share
2 answers

A null pointer means that the pointer does not point to anything, or in some languages ​​it means that it is not known what it points to. But since this is a null pointer, you know this, the code knows about this, so there is no problem. A dangling pointer is one that, in your opinion, points to something, but in fact it is no longer there, so the pointer is actually inaccurate, but does not know it.

+8
source

Index Terminology:

  • Dangling (or wild) pointer: A pointer that points somewhere but not a valid object.
  • Pointer to pointer: a pointer to a specially allocated location outside the limits in which programs will never store data legally. Special class of a hanging pointer.
  • Uninitialized pointer: a pointer that has never been bound to the address of something. Type of dangling pointer.
  • Pointer stale: a pointer that once pointed to something, but the target was deleted (either using the delete operator, or free, or out of scope). Type of dangling pointer.

Pointers that dangle can be said to indicate hyperspace or another dimension, with the exception of the null pointer, which is usually called "Nothing."

+11
source

Source: https://habr.com/ru/post/1437651/


All Articles