https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114867
--- Comment #1 from m.cencora at gmail dot com --- The unreduced code is actually a regression from gcc-12. @Jonathan Wakely: Could you maybe workaround it in libstdc++ by declaring the std::swap overload for exception_ptr in additional inline namespace in std, like this: namespace std { namespace __exception_ptr { class exception_ptr; void swap(exception_ptr& a, exception_ptr& b); } using __exception_ptr::exception_ptr; inline namespace __exception_ptr_swap { using __exception_ptr::swap; } }