gcc-3.0 bug - destructor not called when throwing an exception
Alexandre Oliva
aoliva@redhat.com
Sat Jul 28 20:17:00 GMT 2001
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
More information about the Gcc-bugs
mailing list