News for hackers. Stuff that matters.
Re:Teardown of a Failed Linux LTS Spectre Fix by nickpsecurity on Wednesday September 04, 2019 @03:23PM (#20880538)
Your statement equates not using exceptions with no error handling at all. Are exceptions the only way C++ can handle errors? Or can it do things like return codes used in C or advanced constructs via its metaprogramming?
Re:Teardown of a Failed Linux LTS Spectre Fix by tomjakubowski on Wednesday September 04, 2019 @10:24PM (#20883343)
You can use error codes or, better, a Result<T, E> template in C++, but throwing an exception is the only sane way to signal an error from a C++ constructor that I know of. The alternatives are awkward: you either stick an error code on the struct, which the caller can check after construction, or write an error code to the caller through an out parameter. In either case, the class implementation now must be concerned with handling objects in some partly-initialized, "error" state.
Re:Teardown of a Failed Linux LTS Spectre Fix by ncmncm on Thursday September 05, 2019 @02:28AM (#20884335)
Error handling without exceptions tends to 3x to 5x as much raw code, with corresponding numbers of errors and poorly-exercised paths. Exception paths rely mostly on destructors which are otherwise well-tested in normal operation.