Maybe someone could tell me why this exception isn't caught? I'm not sure whether it's a compiler bug. It used to work under gcc-2.96 (RedHat). It's a snippet as I can't seem to get it to fail if I compile it by itself...
void param::interpret_and_catch() { try { throw except_invalid_at_file("foo"); interpret(); } catch(const except_invalid_at_file e) { cerr << "Cannot open parameter file " << e() << "\n\n"; show_autohelp(); } catch(const except_returnstr e) { cerr << "Option " << e() << " invalid\n\n"; show_autohelp(); } }
where:
class except { public: };
class except_returnstr : public except { public: except_returnstr(const std::string& uswitch) : m_switch(uswitch) {} const std::string &operator()() const { return m_switch; } private: const std::string m_switch; };
class except_undef_switch : public except_returnstr { public: except_undef_switch(const std::string &uswitch) : except_returnstr(uswitch) {} };
the code core when run. gdb shows
#0 0x41000c32 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 #1 0x4103f989 in raise () from /lib/tls/libc.so.6 #2 0x41041342 in abort () from /lib/tls/libc.so.6 #3 0x00e3b727 in __cxxabiv1::__terminate(void (*)()) ( handler=0x41041170 <abort>) at ../../../../gcc-3.2.1/libstdc++-v3/libsupc++/eh_terminate.cc:47 #4 0x00e3b774 in std::terminate() () at ../../../../gcc-3.2.1/libstdc++-v3/libsupc++/eh_terminate.cc:57 #5 0x00e3b8e6 in __cxa_throw (obj=0x9853630, tinfo=0x0, dest=0) at ../../../../gcc-3.2.1/libstdc++-v3/libsupc++/eh_throw.cc:77 #6 0x08055197 in parammm::param::interpret_and_catch() (this=0xbfff8cc0) at param.cc:95
The compiler options are pretty standard (-O0 -g -Wall).
Thanks
Jeremy
-- Jeremy Sanders <jss@xxxxxxxxxxxxx> http://www-xray.ast.cam.ac.uk/~jss/ X-Ray Group, Institute of Astronomy, University of Cambridge, UK. Public Key Server PGP Key ID: E1AAE053