This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
when do object destructors get implicitly called
- To: gcc-help at gcc dot gnu dot org
- Subject: when do object destructors get implicitly called
- From: "Clint Laschkewitsch" <clintl at us dot ibm dot com>
- Date: Mon, 9 Jul 2001 16:37:07 -0500
I'm looking at writing some C++ application level code to run on top of
Linux. It would be compiled with the GNU gcc compiler for a 405 PowerPC
processor. Not sure, yet, which version of the compiler...2.95 or 3.0.
If the version makes a difference, let me know.
Questions have come up about how good the compiler and Linux implemantation
are in regard to running object destructors. That is, how robust is the
combination of gcc and Linux in getting destructors run when an object goes
out of scope.
For example, I assume the simple cases of an object being created inside a
code block and the end of the code block being reached or the return from
main would run the destructors for objects within that scope.
But what about more complex problems that cause a process to end? Such as
someone doing a kill on some daemon process. Or some signal being sent to
a process which causes the process to die. Will the object destructors get
called in these cases?
What if we are talking about a multi-threaded process? If some secondary
thread dies that has created objects, are destructors for the thread run in
that case? Or what if the parent thread kills a child thread? Do
destructors in the child thread get called?
I'm trying to understand the situations in which an object's destructor
would not get implicitly called and what kind of robust error recovery code
I have to wrap around a process or thread so that I can explicitly call
object destructors.
Thanks in advance for any insight you can give me.