This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Bug in implementation of C++ ABI exception handling?
- From: Chris Lattner <sabre at nondot dot org>
- To: gcc at gcc dot gnu dot org
- Date: Sun, 24 Aug 2003 22:56:55 -0500 (CDT)
- Subject: Bug in implementation of C++ ABI exception handling?
Section 2.4.1 (http://www.codesourcery.com/cxx-abi/abi-eh.html#cxx-throw)
of the C++ ABI says (roughly): if an exception is thrown by the copy
constructor which copies an exception value into the exception object, the
currently allocated exception object is freed and the thrown exception
propagates instead.
Currently, in this situation, G++ calls terminate instead.
Here's a testcase:
#include <stdio.h>
struct foo {
foo() {}
foo(const foo &F) { throw 1; }
};
int main() {
try {
foo f;
throw f;
} catch (int i) {
printf("Success!\n");
return 0;
} catch (foo &f) {
printf("Failure: caught a foo!\n");
return 1;
} catch (...) {
printf("Failure: caught something else!\n");
return 1;
}
}
Am I missing something, or should this print "Success" instead of
aborting?
-Chris
--
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/