Date: Fri, 28 Aug 2026 16:13:12 +0200
Yes, sorry. h(g(f(x))) was not meant as a C++ expression, but how the function call each other.
In full notation it would be:
// f throws an exception
int f(int x) {
throw std::exception();
return x * x;
}
// g does not have to care
int g(int x) {
return 4 * f(x);
}
// h catches the exception
int h(int x) {
try {
int y = g(x);
} catch(const std::exception& e)
{
// handle it
}
return y + 2;
}
-----Ursprüngliche Nachricht-----
Von:Rainer Deyke via Std-Proposals <std-proposals_at_[hidden]>
Gesendet:Fr 28.08.2026 14:16
Betreff:Re: [std-proposals] fine-control exception/error/UB handling on function boundary
An:std-proposals_at_[hidden];
CC:Rainer Deyke <rainerd_at_[hidden]>;
On 8/28/26 12:08, Sebastian Wittmeier via Std-Proposals wrote:
> h(g(f()))
>
>
> One important philosophy of exceptions is that code in-between - like the function g - does not have to care, what kind of exceptions are thrown by f, as long as h handles it.
Neither g nor h will ever see the exception if f throws. Neither g nor
h have the opportunity to handle the exception. Neither g nor h will
even be called.
--
Rainer Deyke - rainerd_at_[hidden]
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2026-08-28 14:19:24
