Archived

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

Freaker13

Debug error

Recommended Posts

Hi all, i get The folowing error: debug error: DAMAGE :after Normal block (#44) at 0x00421ED0 i dont get the error when i remove the command a = b; in the folowing function:
template<class T>
void iSortStrategy<T>::swap(T& a,T& b)
{
	T temp = a;
	a = b;
	b = temp;
}
can someone help me???? thx in advance [edited by - freaker13 on May 27, 2004 2:54:58 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
There is nothing wrong with the code you posted. The problem is somewhere else. My guess is that when temp''s destructor is called, it deallocates memory "owned" by a. You need to overload the copy constructor and assignment operator to implement a proper copy operation. You can avoid the issue by swapping pointers rather than the objects themselves.

As a side note, rather than implement your own swap function, you could use the STL version (which is identical to yours).

Share this post


Link to post
Share on other sites
Do you get the same regardless of a debug or release build? You might want to check that you are not mixing debug and release builds of other libs that are being linked with your app. The error you are getting looks like some kind of heap corruption. This has caught me out in the past.

Share this post


Link to post
Share on other sites