https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90295

Mathias Stearn <redbeard0531 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |redbeard0531 at gmail dot com

--- Comment #2 from Mathias Stearn <redbeard0531 at gmail dot com> ---
This will become more of a problem with C++ coroutines where in many cases the
compiler can prove that no exception will be thrown, but the generator or task
type will still have overhead from an exception_ptr member that the compiler
can't eliminate at the moment.

A handful of additional methods should probably either be completely inline or
have a nullptr fast-path: https://godbolt.org/z/zP6DSJ

default ctor
copy ctor
copy assign
swap
operator==
operator!=

Example showing significant codegen at -O3 which should all optimize away:

#include <exception>
bool test() {
    std::exception_ptr p1;
    std::exception_ptr p2 (p1);
    p1 = p2;
    swap(p1, p2);
    return p1 == nullptr && nullptr == p2 && p1 == p2;
}

Reply via email to