This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/3768: GCC 3.0 fails to call destructors when expceptions thrown from try block



>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]