Wild pointer dangling pointer and dangling reference

Source: Internet
Author: User

An empty-hanging pointer is a pointer to a normal initialization of a pointer that once pointed to a normal object, but the object is destroyed, and the pointer is not empty and becomes a dangling pointer.

A wild pointer is a pointer to an uninitialized pointer whose pointer content is a garbage number. (In general, when we define a pointer, it is initialized to null or directly to the address of the variable you want to point to, but if we do not point to null or the variable address is used for the pointer, the memory address pointed to by the pointer is random). The presence of a wild pointer is a serious error.

int main () {    int *p;//pointer uninitialized, at which point P is the wild pointer     int *pi = nullptr;    {        int i = 6;        PI = &i; At this point the pi points to a normal address        *pi = 8;//OK    }       *pi = 6;//Because the PI pointer to the variable i has been destroyed, the PI is now a dangling pointer    return 0;

  

Wild pointer dangling pointer and dangling reference

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.