3 ms·
> Every C++ functional call that can throw adds several instructions of overhead to save information about the call stack and check the return value That's not
by cesarb 10y ago
> Every C++ functional call that can throw adds several instructions of overhead to save information about the call stack and check the return value
That's not how it works (unless you're using 32-bit Windows). I wrote a long explanation using an old gcc on Linux at https://stackoverflow.com/questions/307610/how-do-exceptions-work-behind-the-scenes-in-c/307716#307716 https://stackoverflow.com/questions/307610/how-do-exceptions...
Basically, calling a function that can throw doesn't save any information (other than what it already has to save to do the call), and it doesn't check any return value (other than any check on the return value you wrote yourself). Instead, the exception machinery uses compiler-generated tables, keyed to the return address, to direct the execution flow to the correct landing pad.