C++ Logo


Advanced search

Re: [std-proposals] RTTI in current_exception

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 09 Jan 2023 16:22:52 -0800
On Monday, 9 January 2023 14:43:24 PST Frederick Virchanza Gotham via Std-
Proposals wrote:
> Personally I never throw anything that doesn't inherit from std::exception,
> so this isn't really for me. But I have to interact with shared
> libraries provided
> by other people though, and that's why I want the Committee to choose
> one of the following for C++26:
> Choice 1: Deprecate the throwing of non-std::exception's.
> Choice 2: Provide RTTI inside catch(...)

Choice 3: do neither.

As I said, throwing types not derived from std::exception should be
discouraged by recommendation. The language doesn't need to enforce that
because the *Core* language doesn't need to know anything about
std::exception. It's just a polymorphic type like any other, to which the
Standard *Library* assigns special meaning and we all by convention agree to

> And yeah I'd probably print debugging information if an unhandled exception
> propagated all the way up to a 'catch(...)' body inside 'main', or perhaps
> send some error info out over a HTTP socket I have going.

Realistically, the only things that will hit a catch (...) and not a
catch (std::exception &) are foreign exceptions. There won't be a typeinfo for
them in the first place.

The proposal needs to deal with that non-hypothetical.

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-01-10 00:23:04