https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117785
Hana Dusíková <hanicka at hanicka dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hanicka at hanicka dot net
--- Comment #1 from Hana Dusíková <hanicka at hanicka dot net> ---
It's not part of the wording as CWG told me to take it out. But it's very
useful when an exception is not caught to call it's `.what()` and print
resulting message as part of the error. If there is no `.what()` available,
just print it structurally.
https://compiler-explorer.com/z/Gn6xYbKoY
```c++
struct division_by_zero {
constexpr const char * what() const noexcept {
return "thou shall not divide by nothing 😱";
}
};
constexpr unsigned divide(unsigned a, unsigned b) {
if (b == 0) {
throw division_by_zero{};
}
return a / b;
}
constexpr auto v = divide(3, 0);
```
Gives this error in my prototype:
```c++
<source>:14:16: error: constexpr variable 'v' must be initialized by a constant
expression
14 | constexpr auto v = divide(3, 0);
| ^ ~~~~~~~~~~~~
<source>:9:9: note: unhandled exception: thou shall not divide by nothing 😱
9 | throw division_by_zero{};
| ^
```
Even further (and I'm still working on it) would be good to implement extension
which takes anything convertible to `basic_string_view` and then print it.
Note P3560R0 "Error Handling in Reflection" has std::meta::exception type with
`u8string_view what()` member.