473,419 Members | 1,889 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,419 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 13985
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: 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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.