This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc-3.0 bug - destructor not called when throwing an exception
- To: Phil Edwards <pedwards at disaster dot jaj dot com>
- Subject: Re: gcc-3.0 bug - destructor not called when throwing an exception
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 29 Jul 2001 00:16:20 -0300
- Cc: Ryszard Kabatek <Ryszard dot Kabatek at softax dot pl>, gcc-bugs at gcc dot gnu dot org
- Organization: GCC Team, Red Hat
- References: <3B616112.3B617086@softax.pl><20010727132755.F6147@disaster.jaj.com>
On Jul 27, 2001, Phil Edwards <pedwards@disaster.jaj.com> wrote:
> No, GCC is correct here, I believe. Let's go to the C++ standard:
> # [15.2]/1
> # As control passes from a throw-expression to a handler, destructors
> # are invoked for all automatic objects constructed since the try block
> # was entered.
> The ctor for 'a' finished before the try block was entered.
Not before the try block whose catch caught the exception, which is
the one that matters. If this were not the case, exception-handling
would be severely broken in C++, as there would be no guarantee that
stack unwinding would destruct all objects in the path from the throw
to the catch. Unfortunately, this appears to be the case in GCC 3.0.
This would qualify as a high-priority bug, since it's a regression
from 2.95.2. It must definitely be added to the Gnats database.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me