Bug in implementation of C++ ABI exception handling?
Chris Lattner
sabre@nondot.org
Mon Aug 25 14:05:00 GMT 2003
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/
More information about the Gcc
mailing list