This is the mail archive of the gcc@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]
Other format: [Raw text]

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/


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