Original Post
I've been programming in C for a long time now (not necessarily through choice, it's what we use at work) but have frequently had to dabble with C++, often when interfacing with other peoples' or library code. But, I'm aware my understanding of C++ is not as good as it could be, and with some big deadlines out of the way I figure now's as good a time as any to fix that. Today's problem :-) is exceptions. So, I understand the concept of using them, and can write syntactically correct code to use them (though I still think it's horrifically ugly, I don't like the code that using them produces). My problem is, I just don't get what they're doing on the stack. Calling functions is easy - the code just pushes and pops various different variables and program counters onto and off the stack, no worries, easy as you like. But I don't see how exceptions could work the same way (how would you know the difference between returning from a function and throwing an exception from it?) and it confuses me. Could somebody please take a few moments to briefly explain what happens at a low level when an exception is thrown (and caught)? I'd much appreciate it!