473,322 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

scalar deleting destructor

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
4 13973
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Thomas Philips | last post by:
I'm teaching myself OOP using Michael Dawson's "Python Programming For The Absolute Beginner" and have a question about deleting objects. My game has two classes: Player and Alien, essentially...
6
by: Thomas Philips | last post by:
I have a question about deleting objects. My game has two classes, Player and Alien, essentially identical, instances of which can shoot at each other. Player is described below class...
15
by: Rick | last post by:
Hi, Does deleting an object more than one times incur undefined behavior? I think it doesn't but just making sure... thanks Rick
9
by: Aguilar, James | last post by:
Hey guys. A new question: I want to use an STL libarary to hold a bunch of objects I create. Actually, it will hold references to the objects, but that's beside the point, for the most part. ...
1
by: Woonggi | last post by:
help me~~~
2
by: maynard | last post by:
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...
3
by: Andy | last post by:
Hello, I have the following situation: Thread A is allocating a dataset, doing some low-level calculations and storing a pointer to the dataset in a std::list via push_back. Thread B should...
10
by: H.S. | last post by:
Hello, I have class in which I am allocating space for a double array in the constructor. I use the double array twice in one of the methods and then delete that array in the class's destructor....
12
by: mc | last post by:
Hi Experts, This may be obvious but I can't find anything one way or another. We have a class which is always allocated using new, e.g. Foo* foo = new Foo() so we came up with the idea of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.