I would expect a C++ compiler to generate optimal and equivalently efficient code for both of the functions below. gcc 4.3 generates much worse code for bar() than for foo() even at -O3.
int foo () { return 1; } int bar () { try { throw 1; } catch (int i) { return i; } } -- Summary: inefficient code on trivial try/catch statement Product: gcc Version: 4.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sebor at roguewave dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38658