This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/7399: Exception object destructors called pre-maturely.
- From: bangerth at dealii dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, lclay at ecustomers dot com, nobody at gcc dot gnu dot org
- Date: 17 Dec 2002 00:45:10 -0000
- Subject: Re: c++/7399: Exception object destructors called pre-maturely.
- Reply-to: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, lclay at ecustomers dot com, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: Exception object destructors called pre-maturely.
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Mon Dec 16 16:45:09 2002
State-Changed-Why:
With gcc3.3 I get the result you expect, with 3.2 I get
memory corruption. However, if you insert a copy constructor
for your MyException class and let it output something, you'll
easily see that it is called in the process of throwin
an exception (at least with 3.2, and probably also with
2.96), which easily explains what is going on. Upshot:
don't do that, i.e. when you allocate memory in a class,
you have to do a deep copy in the copy constructor, or you
have to do counted pointers.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7399