Throughout the function handleException, the exception encountered is implicit. How does the compiler handle such implicit passing of exceptions? [For e.g. in C++ methods, this pointer is passed to account for the current object. My question is how does a compiler handle exceptions internally - handleException has no arguments.]  void handleException() {   try {     throw;   }   catch (MyException& e) {     ...code to handle MyException...   }   catch (YourException& e) {     ...code to handle YourException...   } } void f() {   try {     ...something that might throw...   }   catch (...) {     handleException();   } }
How does compiler handle exceptions that are implicit? Looking for design strategies
c++;exceptions;compiler
Pay no attention to that man behind the curtain.Because the compiler knows how it implements exceptions, it can use that internal information.  The simplest way is to use a global (or thread local) variable to store info about any active exception; then retrieve that, mostly to get type info, and propagate.  C++0x partially exposes this information with std::exception_ptr; see 18.8.5 in N3225.Exceptions are handled differently from parameters; analogy to this won't be helpful.  The value for this is usually treated as a normal pointer parameter, except for being hidden from the user behind the curtain.