From: Asfand Yar Qazi Date: 2004-01-18T18:49:59+09:00 Subject: Re: C++ from Ruby ARRRGGHH!! nobu.nokada@softhome.net wrote: > Hi, > > At Sun, 18 Jan 2004 16:20:01 +0900, > Asfand Yar Qazi wrote: > >>Anyway, could you look at the following test code that reveals the >>problem? I just don't know what to do! Are C++ exceptions in GCC >>incompatible with Ruby exceptions? I think that's the problem, isn't it... > > > Yes, of course, incompatible. They aren't concerned with at > all. You have to protect or wrap each exceptions at every > boundaries. > As you can see from the code... #define CHECK_CPP(code) try {code;} \ catch(std::exception& e) {raise_ruby(e);} i.e. catch a C++ exception, wrap its contents in a Ruby exception, dispatch that Ruby exception. But that corrupts the program stack I think, resulting in really funny and annoying errors (as documented in the OP), and eventually resulting in a coredump. Its all due to the setjmp/longjmp used by Ruby exceptions and GCC's advanced exception-handling mechanism, which are incompatible. I wait for the day when a scripting language will be written in C++, and be fully compatible will C++ features (perhaps even with templates.) But still, I'll just redo my C++ code in a Ruby-esque way, i.e. throwing Ruby exceptions instead of C++ exceptions, so no problems. -- http://www.it-is-truth.org/