Re: Try/Catch

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...

Arguments aside, I think the next (small) step, in the investigation process, is for someone to translate eg

puts(1,"started\n") 
--try 
puts(1,9/0) 
--catch 
puts(1,"exception caught\n") 

and then see if they can modify the resulting C code to use setjmp/longjmp and survive.

Then repeat the process with the 9/0 several nested calls deep away, and finally post the C source mods here.

Funny you should mention setjmp/longjmp, I've been working on trying to figure out how exactly that would work in a C program. The big problem is that you need to cleanup and call destructors for objects in the functions that are getting jumped over getting to the catch block. Registering a cleanup function is possible with GCC's cleanup variable attribute, but it doesn't work because longjmp ignores them. Then I found libunwind-setjmp which should unwind the stack and call cleanup functions, but my test doesn't seem to be using the right longjmp.

Another option would be to translate to C++ and use try/catch natively. tongue

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu