This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: uncaught exception in g++ 3.4 and 4.0
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 12 Sep 2005 11:45:13 -0700
- Subject: Re: uncaught exception in g++ 3.4 and 4.0
- References: <17185.27267.358941.484622@zapata.pink>
Andrew Haley wrote:
> There's a thread at
> http://groups.google.co.uk/group/gnu.gcc.help/tree/browse_frm/thread/e85dce7d69fb7dc1
> which looks odd. It seems that the exception filter is not being
> correctly processed.
>
> I can't find a Bugzilla entry for this. Is it really a bug?
>
> Andrew.
>
> quoted message --------------------------------------------------------
> From: "Mark Nelson" <snorkel...@gmail.com>
> Newsgroups: gnu.gcc.help
> Subject: uncaught exception in g++ 3.4 and 4.0
> Date: 13 Aug 2005 08:35:46 -0700
>
> I have a case where an exception in the constructor of class with a
> virtual base leads to termination:
>
> struct vbase {};
>
> struct foo : virtual vbase {
> foo() {
> throw "exception in foo ctor";
> }
>
> };
>
> main()
> {
> struct bar : public foo {};
> try {
> bar a;
> }
> catch ( ... ) {
> }
> return 0;
>
> };
>
> This program demonstrates the problem in g++ 3.4 a 4.0.0. Instead of
> catching
> the exception, the program terminates. The base dtor gets called as
> expected, but upon return, there is some generated code that I can't
> decipher, which jumps to some termination code at bad_alloc + 80.
>
> That should be a clue... but I'm unable to catch it.
The exception should be caught. The destructor for vbase should be run,
but the destructors for foo and bar should not be, as foo was never
completely constructed. Then, the catch-clause should run, and the
program should return 0.
I suspect the bug is in the logic for computing the exception
specification for the implicitly-defined bar::bar() constructor. It
should allow all exceptions, since the base class constructor does.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304