https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90295
Bug ID: 90295 Summary: Please define ~exception_ptr inline Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: rafael at espindo dot la Target Milestone: --- Currently ~exception_ptr is defined out of line. Its definition just calls _M_release which looks like if (_M_exception_object) { ... } Which means that there is nothing to do for an exception_ptr that has been moved, but the user code has no way of knowing that. If the ~exception_ptr was defined inline as ~exception_ptr() { if (_M_exception_object) { out_of_line_destructor(); } } Then the compiler would be able to omit the call to out_of_line_destructor when it knows _M_exception_object is null. This comes up in seastar (https://github.com/scylladb/seastar/) where we have a struct (future_state) that holds a exception_ptr and is frequently moved.