public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: austin@ww.c.onz
To: gcc-gnats@gcc.gnu.org
Subject: c++/3768: GCC 3.0 fails to call destructors when expceptions thrown from try block
Date: Sun, 22 Jul 2001 22:26:00 -0000	[thread overview]
Message-ID: <20010723052402.19498.qmail@sourceware.cygnus.com> (raw)

>Number:         3768
>Category:       c++
>Synopsis:       GCC 3.0 fails to call destructors when expceptions thrown from try block
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 22 22:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Austin Green
>Release:        gcc version 3.0
>Organization:
>Environment:
Solaris 8 on Intel Pentium
Full gcc -v output:
$ gcc -v
Reading specs from /opt/bin/gnu/../lib/gcc-lib/i386-pc-solaris2.8/3.0/specs
Configured with: ../gcc-3.0/configure --prefix=/opt/gnu --with-gnu-as --with-as=/opt/bin/gnu/as --with-gnu-ld --with-ld=/opt/bin/gnu/ld --with-gxx-include-dir=/opt/gnu/include/g++ --enable-threads=posix
Thread model: posix
gcc version 3.0
>Description:
When an exception is thrown from within a 'try' block, and not caught in the associated 'catch' block but propagated up to the calling function, the destructors of variables declared before the 'try' block are not called.
>How-To-Repeat:
Compile the small sample program attached.
Run it with no arguments for 'proper' behaviour.
Run it with any argument to show the fault.
>Fix:
No fix, but a work-around is as follows:
Surround the offending try/catch blocks and their preceding variable declarations with another try/catch block.  In this outer catch block, catch all exceptions and re-throw.
This is, in essence, what the compiler ought to be doing.
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2001-07-22 22:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-22 22:26 austin [this message]
2001-08-03 17:04 rth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010723052402.19498.qmail@sourceware.cygnus.com \
    --to=austin@ww.c.onz \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).