https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68297
Bug ID: 68297 Summary: Faster std::make_exception Product: gcc Version: 5.1.1 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: nyh at math dot technion.ac.il Target Milestone: --- std::make_exception(object) currently does this: make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT { try { throw __ex; } catch(...) { return current_exception(); } } I think this could have been made much faster... Throwing an exception is very slow, and not really needed here, as gcc (libsupc++) knows exactly how to create an exception_ptr from the given object, without going through the motions of looking for the exception frame (we know exactly where it will be). By taking the right code from __cxa_throw, std::current_exception(), etc., this can be done without any stack unwinding, and therefore much more quickly. Such an improvement will benefit especially code that passes around exception_ptrs instead of actually throwing exception (the Seastar library, for example, does this).