C++ Logo

std-proposals

Advanced search

Re: Stacktrace from exception

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Thu, 29 Apr 2021 19:18:46 +0300
On 4/29/21 7:08 PM, Edward Catmur wrote:
> On Thu, 29 Apr 2021 at 17:02, Andrey Semashev via Std-Proposals
> <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>>
> wrote:
>
> On 4/29/21 6:44 PM, Edward Catmur wrote:
> > Quick sketch: the compiler sets a directive at the catch site to
> request
> > stacktrace,
>
> The compiler would do that based on what?
>
> Based on whether it can observe a call to std::current_exception or
> std::current_exception_stacktrace, a throw; or a call which may end up
> performing any of those.
>
> Yes, yes, I know, you're calling outside the TU to log the exception but
> nevertheless find the cost of a 80-byte allocation for a stacktrace
> prohibitive. I'm talking about optimizing the exceptions-as-control-flow
> usage where the catch block is trivial.

Whether that call to another TU is logging or something else is
irrelevant. The important part is that your suggested way of detecting
the need for a stacktrace doesn't work in general.

Received on 2021-04-29 11:19:02