C++ Logo

std-proposals

Advanced search

Re: Stacktrace from exception

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Thu, 29 Apr 2021 15:39:38 +0100
On Thu, 29 Apr 2021 at 13:28, Andrey Semashev via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On 4/29/21 3:22 PM, Edward Catmur wrote:
> > The TU of the throw site is irrelevant; collecting the stack trace
> > during unwinding is performed by the runtime, not by the throwing code.
>
> Presumably, someone has to tell the runtime to collect the stacktrace,
> and, if I understood you right, that someone is supposed to be the
> compiler, which sees a std::current_exception_stacktrace call in the
> catch block.
>

Yes? That sounds entirely feasible.

> If the catch site calls outside its own TU then yes, the compiler should
> > assume that it may access the exception stack trace. But if it's being
> > used for control flow then it won't call outside its own TU since the
> > exception is expected.
>
> I don't see how you arrive to this conclusion. And a catch handler
> absolutely will contain a call to a different TU, even if to merely log
> the event.
>

If you're using exceptions for control flow, why are you logging them? And
if you're logging them, why are you concerned about an ~80 byte allocation
for a stack trace?

Received on 2021-04-29 09:39:51