473,386 Members | 1,745 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,386 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 13981
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.