Recent versions of libgcc and libstdc++abi contain a version of std::terminate() that catches std::exception and prints an error message, so you don't need the debugger for that anymore.
On the other hand, there is still the issue that uncaught exceptions cause a very messy program shutdown - the compiler doesn't even have to guarantee stack unwinding, let alone execution of global finalizers (like destructors of singletons). Pretty much the only thing that's guaranteed (by the OS, basically) is that your memory will be released, your files closed and all of your streams flushed before that (but maybe only stdin, stdout and stderr). So if you have some other state that you need to clean up (like removing a semaphore or finalizing a pending asynchronous HDF5 write that shouldn't fail just because the iterative solver did not converge in your next iteration), you're probably SOL.
So I don't like the idea of teaching people that the way to reliable programs is to just let exceptions propagate...
@oliver.sander If the error message is all you're after, compiler support for that at least looks rather good:
#include<exception>classC:publicstd::exception{constchar*what()constnoexceptoverride{return"some random error";}};intmain(){throwC();}
% clang++ -std=c++14 -stdlib=libstdc++ foo.cc && ./a.out terminate called after throwing an instance of 'C' what(): some random errorzsh: abort ./a.out% clang++ -std=c++14 -stdlib=libc++ foo.cc && ./a.outterminating with uncaught exception of type C: some random errorzsh: abort ./a.out% g++ -std=c++14 foo.cc && ./a.out terminate called after throwing an instance of 'C' what(): some random errorzsh: abort ./a.out% g++-libc++ -std=c++14 foo.cc && ./a.out terminating with uncaught exception of type C: some random errorzsh: abort ./a.out%
So if you have some other state that you need to clean up (like removing a semaphore or finalizing a pending asynchronous HDF5 write that shouldn't fail
I'm not sure what we're talking about here. This is not an issue in tests. So are we talking about user code then? If we have a user who deems HDF5 a suitable IO facility, he or she is the only one who knows what needs to be done to make sure his or her HDF5 files don't end up garbled. So he or she needs to put a catch in the right place, with the right handling. That's clear. Are you worried that if we remove catch clauses from tests that users will stop using exception handling in their own code, too?
If it's guaranteed that the runtime will print the message it's OK.
As far as I understood, this is not the case. But then I don't see the point in changing this. Even if it works in all cases, saving these one or two lines does not improve clarity to users. Currently you can clearly see what's going on. This changes if we rely on magic that isn't documented properly (i.e. in books/iso standard/cppreference) because it's non-standard.
There is no consensus. I'll revoke my merge request for dune-grid-howto and modify it to remove the catch for Dune::Excpetion which is already handled by std::exception.