issue deleting template class object

M

maynard

I have defined a template class (tree data structure) that uses dynamic
memory and has properly implemented ctor's, dtor and assignment
operator. I can observe the address of my tree object prior to the
destructor being called, and then the address once inside the
destructor...they're different! The following calls are on the stack
between the call to my destructor and the actual destructor itself:

`eh vector destructor iterator'(void * ptr=0x00a6c454, ...)
`vector deleting destructor'()

I've also noticed that the address passed as "ptr" in the "eh vector
destructor iterator" is the address that my tree object has once inside
the destructor (again...it's not the same address prior to the
destructor being called). This is causing a run time exception (the
passed address points somewhere that isn't initialized to anything).

What exactly do the above methods do? BTW, I'm debugging with MS VC++
..NET.
 
V

Victor Bazarov

maynard said:
I have defined a template class (tree data structure) that uses
dynamic memory and has properly implemented ctor's, dtor and
assignment operator. I can observe the address of my tree object
prior to the destructor being called, and then the address once
inside the destructor...they're different! The following calls are
on the stack between the call to my destructor and the actual
destructor itself:

`eh vector destructor iterator'(void * ptr=0x00a6c454, ...)
`vector deleting destructor'()

I've also noticed that the address passed as "ptr" in the "eh vector
destructor iterator" is the address that my tree object has once
inside the destructor (again...it's not the same address prior to the
destructor being called). This is causing a run time exception (the
passed address points somewhere that isn't initialized to anything).

What exactly do the above methods do? BTW, I'm debugging with MS VC++
.NET.

It might be best to ask in a VC++ newsgroup. Unless you feel like
following the recommendations of FAQ 5.8.

V
 
G

Gianni Mariani

maynard said:
I have defined a template class (tree data structure) that uses dynamic
memory and has properly implemented ctor's, dtor and assignment
operator. I can observe the address of my tree object prior to the
destructor being called, and then the address once inside the
destructor...they're different! The following calls are on the stack
between the call to my destructor and the actual destructor itself:

`eh vector destructor iterator'(void * ptr=0x00a6c454, ...)
`vector deleting destructor'()

I've also noticed that the address passed as "ptr" in the "eh vector
destructor iterator" is the address that my tree object has once inside
the destructor (again...it's not the same address prior to the
destructor being called). This is causing a run time exception (the
passed address points somewhere that isn't initialized to anything).

Are you slicing the object ?

Slicing refers to objects with a non-virtual destructor where you end up
deleting the wrong object. The same happens with copies.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top