|
From: | Larry I Smith |
Subject: | Re: Exceptions failing in libstdc++ |
Date: | Mon, 21 Mar 2005 20:21:50 GMT |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041220 |
red floyd wrote:
G++ 3.2.3 (RedHat Enterprise Linux 3), x86 g++ --version returns: g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-49)Boiled down to essentials (and unfortunately, the minimun example won't barf), I have:class X { public: X() { /* ... */ }; // ... etc etc... }; void f() { throw X(); } void g() { // yada yada yada try { f(); } catch (X&) { // do something } } But when f() throws X as an exception, the program terminates, and the libstdc++ code in __cxa_throw has a comment of: // Some sort of unwinding error. Note that terminate is a handler. __cxa_begin_catch (&header->unwindHeader); std::terminate (); The full-bore code in question works properly under VC7.1GDB shows that the call to f() is occuring within a try/catch block, which catches X&.I'm compiling with -pthread -fexceptions Any suggestions?
Exceptions work fine in GCC. Your minimal example verifies that. The '-fexceptions' flag is not required. 'g++' always enables exceptions for C++ source files. That flag may be of use when compiling C source files that will be linked with C++ files (see 'info gcc' for details). You've probably uncovered a flaw in your program (stack being overwritten, flaw in X() constructor, etc, etc) that is causing the exception handling info on the stack to become corrupted. Things are laid out differently in memory (gcc vs msvc); even struct sizes and layouts may differ. Regards, Larry -- Anti-spam address, change each 'X' to '.' to reply directly.
[Prev in Thread] | Current Thread | [Next in Thread] |