By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,242 Members | 863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,242 IT Pros & Developers. It's quick & easy.

scalar deleting destructor

P: n/a
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

Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
al havrilla wrote:
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::operator 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[i].~A();
A::operator 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
Nov 16 '05 #2

P: n/a
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 havrilla wrote:
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 everyclass with a destructor. The "scalar deleting destructor" for class A isroughly equivalent to:

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

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

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

When you write

A* pa;
// ...

delete pa;

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

HTH

-cd
.

Nov 16 '05 #3

P: n/a
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 havrilla wrote:
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 everyclass with a destructor. The "scalar deleting destructor" for class A isroughly equivalent to:

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

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

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

When you write

A* pa;
// ...

delete pa;

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

HTH

-cd
.

Nov 16 '05 #4

P: n/a
al havrilla wrote:
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
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.