scalar deleting destructor

A

al havrilla

hi all

what does the phrase: "scalar deleting destructor" mean?

i'm getting this in a debug error message using c++ 7.1

thanks

Al
 
C

Carl Daniel [VC++ MVP]

al said:
hi all

what does the phrase: "scalar deleting destructor" mean?

i'm getting this in a debug error message using c++ 7.1

It's the name that's reported for a helper function that VC writes for every
class with a destructor. The "scalar deleting destructor" for class A is
roughly equivalent to:

void scalar_deleting_destructor(A* pa)
{
pa->~A();
A::blush:perator delete(pa);
}

There's a sister function that's also generated, which is called the 'vector
deleting destructor'. It looks roughly like:

void vector_deleting_destructor(A* pa, size_t count)
{
for (size_t i = 0; i < count; ++i)
pa.~A();
A::blush:perator delete[](pa);
}

When you write

A* pa;
// ...

delete pa;

The compiler generates a call to the "scalar deleting destructor" for A. An
analogous case applies to deleting an array.

HTH

-cd
 
A

al havrilla

thanks for the explanation.

i'm getting an unhandled exception when trying to delete
an object. running in DEBUG mode using vc++ 7.1 the call
stack ends up at _CrtIsValidHeapPointer. by looking at
the code here it appears that my pointer is not on the
correct heap. i've checked and rechecked the code and
the object is created via new by a worker thread and
deleted by the same thread. this object is a template:

pRxp = new RxPacket<CH_MSG_RCV_SYNC> ;

the code ran fine under vc++ 7.0 and vc++ 6.

i would greatly appreciate any help

Al




-----Original Message-----
al said:
hi all

what does the phrase: "scalar deleting destructor" mean?

i'm getting this in a debug error message using c++ 7.1

It's the name that's reported for a helper function that VC writes for every
class with a destructor. The "scalar deleting destructor" for class A is
roughly equivalent to:

void scalar_deleting_destructor(A* pa)
{
pa->~A();
A::blush:perator delete(pa);
}

There's a sister function that's also generated, which is called the 'vector
deleting destructor'. It looks roughly like:

void vector_deleting_destructor(A* pa, size_t count)
{
for (size_t i = 0; i < count; ++i)
pa.~A();
A::blush:perator delete[](pa);
}

When you write

A* pa;
// ...

delete pa;

The compiler generates a call to the "scalar deleting destructor" for A. An
analogous case applies to deleting an array.

HTH

-cd


.
 
A

al havrilla

i mix calls to MFC file handling objects like CStdioFile
and at other times i use ofstream etc. can this cause
problems in 7.1 since its more standard compliant?

thanks

-----Original Message-----
al said:
hi all

what does the phrase: "scalar deleting destructor" mean?

i'm getting this in a debug error message using c++ 7.1

It's the name that's reported for a helper function that VC writes for every
class with a destructor. The "scalar deleting destructor" for class A is
roughly equivalent to:

void scalar_deleting_destructor(A* pa)
{
pa->~A();
A::blush:perator delete(pa);
}

There's a sister function that's also generated, which is called the 'vector
deleting destructor'. It looks roughly like:

void vector_deleting_destructor(A* pa, size_t count)
{
for (size_t i = 0; i < count; ++i)
pa.~A();
A::blush:perator delete[](pa);
}

When you write

A* pa;
// ...

delete pa;

The compiler generates a call to the "scalar deleting destructor" for A. An
analogous case applies to deleting an array.

HTH

-cd


.
 
C

Carl Daniel [VC++ MVP]

al said:
thanks for the explanation.

i'm getting an unhandled exception when trying to delete
an object. running in DEBUG mode using vc++ 7.1 the call
stack ends up at _CrtIsValidHeapPointer. by looking at
the code here it appears that my pointer is not on the
correct heap. i've checked and rechecked the code and
the object is created via new by a worker thread and
deleted by the same thread. this object is a template:

pRxp = new RxPacket<CH_MSG_RCV_SYNC> ;

the code ran fine under vc++ 7.0 and vc++ 6.

Does the program involve an EXE and a DLL? The most common situation where
an object is returned to the wrong heap is when it's allocated in a DLL and
freed in an EXE (or another DLL), and at least one of the modules concerned
was linked with the static runtime library. If you do have a DLL/EXE
combination, make sure everything is built with /MD or /MDd.

-cd
 

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

Top