Archived

This topic is now archived and is closed to further replies.

'delete' Assertion Failures

This topic is 4987 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I get an Assertion Failure when I try to delete a previously allocated with ''new'' array of structs. It isn''t being deleted twice or anything. What could cause this?

Share this post


Link to post
Share on other sites
WHAT does the assert say? Exactly?
And, when you post deletion code, you also need to post allocation code.

Dollars to donuts you''re overwriting right before or right after the element. Thus, right after you allocate the element, you should set two data breakpoints in the debugger, one for the address right before element, and one for the address right after element; if you overwrite structures in the heap, these data breakpoints will show you where it happens.

Share this post


Link to post
Share on other sites
quote:
Original post by squicklid
Actually, putting the [] in after delete worked. But I don''t quite understand that.


There are two different types of new and delete operators. One set is new/delete and the other is new[]/delete[]. They must be matched. That''s all.

Share this post


Link to post
Share on other sites