[OT] - C++ exceptions are becoming more and more problematic

deadalnix deadalnix at gmail.com
Wed Feb 23 18:27:45 UTC 2022


On Wednesday, 23 February 2022 at 14:26:41 UTC, matheus wrote:
> Just saw this today:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2544r0.html
>
> Seems relevant to any System Language like D that features 
> Exceptions.
>
> Matheus.

This is an interesting paper, but I'm not sure where they are 
going with it.

Exception are expensive. They need to be used to handle 
unexpected things. That's kind of in the name. Things that happen 
often are not exceptional.

Pretty much all workaround they look at incur some performance 
penalty on the happy path, but this is not a bug, this is a 
feature. Exceptions are very cheap when not thrown, very 
expensive when thrown. This is what you want when handling a 
situation that is exceptional.

The perf they measure for std::expect would be worth 
investigating. Why is it slow?


More information about the Digitalmars-d mailing list