C++ Logo

std-proposals

Advanced search

Re: Stacktrace from exception

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Thu, 29 Apr 2021 16:22:59 +0100
On Thu, 29 Apr 2021 at 15:57, Gašper Ažman <gasper.azman_at_[hidden]> wrote:

> Right, so exceptions are slow and barely optimized:
> https://godbolt.org/z/Y7bxeGT79
>
> but that doesn't mean that program shouldn't be optimized to "mov eax, 5;
> ret". The hilarious bit is that the whole exception throw bullshit still
> happens, even though control flow analysis determined that "mov eax, 5;
> ret" is what the program actually is.
>

That's what's expected to happen, but there's no reason __cxa_throw et al
have to do what they're supposed to, when they're being loaded from a
shared object at run time. Case in point: the demo library mentioned at top
of thread. Maybe if you compiled the whole program including libgcc_s (or
equivalent) and statically linked them with flto? Admittedly maybe
optimizing out eh table searching might be a bit of an ask.

Now, if you make compilers do even more stuff upon an exception throw,
> we'll get even further from having reasonable exceptions.
>

I'm sure they can optimize out an extra allocation. They've been able to do
that for quite some time.

Received on 2021-04-29 10:23:11