Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> But it does need to undo all allocations and such that were made between the exception and the nearest exception handler, doesn't it? Isn't this "unwinding the stack"?

it should do so if you use error codes too - else you've got an incorrect program which leaks things like memory (not too bad on our current computers), file handles (really sucks on windows), sockets (really sucks on linux).



I agree, I was just failing to grasp how the execution path of exception handling code is not "unwinding the stack". The compiler will have to prepare each stack frame and mark what needs to be deallocated and the exception handling code won't just jump straight to the nearest handler, but will visit each stack frame and undo the allocations, calling destructors and such.

On the other hand unwinding the stack is not complex and won't add much to program size.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: