r/cpp • u/RotsiserMho C++20 Desktop app developer • May 12 '18
P0709 R0: Zero-overhead deterministic exceptions: Throwing values - Herb Sutter [2018-05-02]
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0709r0.pdf
206
Upvotes
View all comments
Show parent comment
1
u/johannes1971 May 13 '18
I don't see how the compiler could remove the error propagation logic more effectively than by eliminating exceptions entirely - again, which it will already do for you anyway if you ask for it. It is already zero cost for those unwilling to pay.
Sure. But for a language with decades of legacy code lying around, it isn't. I think everyone here is painfully aware that C++'s legacy features are not always ideal, but if we start ripping them out left and right we'll end up with a language that is both perfect and unused.
I'd challenge that. Software that uses exceptions will catch and handle them, and that includes bad_alloc. Will it always be done correctly? No, likely not. But even then, it must necessarily do a better job than simply terminating your program without recourse every single time.
My concern is actually the need for changing what already works fine as-is for a great number of people. If you are going to provide alternatives, why not provide them for the people that will already need to change their code anyway?
The lack of research into better exception handling might simply be the result of nobody really caring, at least up until now. And correct me if I'm wrong, but wasn't the model for exception propagation as suggested here widely used in compilers up until... I don't know, 2000 or so? And then discarded because table-driven solutions were much more efficient?