C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Adding stacktrace to std::exception
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2020-11-12 09:27:26


чт, 12 нояб. 2020 г. в 17:39, Christof Meerwald via Std-Proposals
<std-proposals_at_[hidden]>:
>
> On Thu, Nov 12, 2020 at 05:14:52PM +0300, Antony Polukhin via Std-Proposals wrote:
> > ср, 11 нояб. 2020 г. в 20:32, Kilian Henneberger via Std-Proposals
> > <std-proposals_at_[hidden]>:
> > >
> > > Hello everyone,
> > > if I am informed correctly, P0881 (https://wg21.link/P0881) has been
> > > approved for C++23.
> > > And I assume this is no new idea (also not to C++), but what do you
> > > think about adding a stacktrace to std::exception?
> > This is a very good idea that was not discussed, because this seemed
> > to be an ABI breaking change.
>
> Wouldn't that add significant run-time overhead to every throw
> expression?

It depends. Some implementations may store the stacktrace entry on
unwinding. That's literally a 1 cmov instruction due to the fact that
the implementation already works with the frame pointer

> This really needs to be opt-in, but in that case you can just get the
> stacktrace in your exception's constructor?

You can use std::stracktrace in your exceptions with C++23. However,
getting stacktraces for any exception out-of-the-box is a tempting
feature, especially for big codebases with legacy parts.

-- 
Best regards,
Antony Polukhin

STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups