4 ms·
In C++?
by anyfoo 8y ago
In C++?
- edflsafoiewq 8y agoYes? Is there a difference in terminology here? Obviously you get a trace to the point of the throw. ~ $ cat a.cxx int a() { throw "a"; } int b() { return a(); } int main() { b(); } ~ $ clang++ -g a.cxx && gdb -ex r -ex bt a.out < ...snipped... > #6 0x0000555555554779 in a () at a.cxx:1 #7 0x0000555555554789 in b () at a.cxx:2 #8 0x000055555555479d in main () at a.cxx:4
- anyfoo 8y agoThere is no catch in your example. I thought the point was that in C++, preserving the stack trace when having caught an exception is rather non-trivial. Exceptions that don't get caught usually allow you to get the stack trace through a crash report/core dump/whatever, but then there's not much difference between an uncaught exception and a plain abort().
- edflsafoiewq 8y agoYes, I said "if you don't catch them you always get a full stack trace". The comparison was between returning error values and exceptions, not between exceptions and abort. The difference is with abort is of course that once you are alerted to the error by seeing it be uncaught, you can insert an appropriate handler for it. A file-open function can throw on file not found but I will not very happy if it aborts.
- anyfoo 8y agoAh, after reading the full thread, that is actually what you said, and I don't really know what the point of the commenter you replied to was, now...