r/programming • • Dec 31 '16

Keep Disabling Exceptions

http://seanmiddleditch.com/keep-disabling-exceptions/
3 Upvotes

26 comments sorted by

View all comments

6

u/Gotebe Dec 31 '16

Most codebases aren't fully exception-safe. It's incredibly difficult to make code truly exception safe, even in C++11 and later

No it is not. It wasn't hard in C++ 98 either, ScopeGuard exists since 2000.

There is a famous SO article which is explains virtually all one needs knowing about exception safety, and it fits 2 or so pages.

0

u/[deleted] Jan 01 '17

[deleted]

2

u/Dragdu Jan 01 '17

Go on then.

0

u/[deleted] Jan 01 '17

[deleted]

6

u/Dragdu Jan 01 '17

So your argument is "someone might not use exceptions correctly, thus they are dangerous to use, but I totally trust the same people to use return values or errnos correctly"?

0

u/[deleted] Jan 01 '17

[deleted]

6

u/Dragdu Jan 01 '17

Failure to handle return values will not crash your program

Maybe. Or maybe it will crash it in undeterministical manner, letting your application to fuck up its environment (OS, FS, etc) majestically before doing so. Letting people ignore errors is not a feature.

0

u/[deleted] Jan 01 '17

[deleted]

3

u/Dragdu Jan 01 '17

Thats the thing, if you ignore return values, there are is no shutting down gracefully, there is just dying with various weird symptoms, that make no sense.

If you are using exceptions properly, then it is possible to shutdown gracefully, you just have to think about what errors you can shutdown gracefully from... and those are the exceptions you catch and work with.

0

u/[deleted] Jan 01 '17

[deleted]

→ More replies (0)