How to solve access violation reading location 0xccccccc0 running exception

Source: Internet
Author: User

The following error occurs during compilation and running.

Access violation reading location 0xccccccc0

One-step debugging: an error occurs when a pointer variable is deleted. The error is caused by the deletion of a pointer variable without a new one.

Therefore, you must carefully check the object creation status before the delete operation.


To sum up the error-prone parts of delete:

 

Int * A = new int [10];
......
Delete [];
----------------------------------------------------------
When Delete [] A; is followed by an error:
1. You intentionally or unintentionally changed the first address of array A, such as a ++;
2. Scope of the variable. For example, if you are new in a function body but delete in another function body, the variable is no longer valid, in this case, the error message "a" is an unknown identifier in the delete statement;
3. the operation has been deleted once. You cannot delete the operation twice;
4. Memory Access out of bounds. VC allocates memory. In addition to allocating the memory space you need, some management units are allocated, which is at the upper and lower bounds of your allocated space, for example, the memory boundary flag (0 xfdfdfdfd) records the number of array elements in the upper bound of the array. If you modify the management information, an error will be reported during the delete operation.

 

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.