Boost logo

Boost :

Subject: Re: [boost] Noexcept
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2017-06-20 23:41:49

On 20/06/2017 20:32, Emil Dotchevski wrote:
> On Mon, Jun 19, 2017 at 11:58 PM, Andrzej Krzemienski wrote:
>> I want to be alerted, and possibly stop what I was
>> debugging before. This default setting is my friend, provided I do not use
>> exceptions for just any "irregularity".
> Exceptions are not used in case of "irregularities" but to enforce
> postconditions. When the program throws, it is in well defined state,
> working correctly, as if the compiler automatically writes "if" statements
> to check for errors before it executes any code for which it would be a
> logic error if control reaches it. The _only_ cost of this goodness is that
> your code must be exception safe.
> Programmers who write debuggers that by default break when a C++ exception
> is thrown likely do not understand the semantic differences between OS
> exceptions (e.g. segfaults, which *do* indicate logic errors) and C++
> exceptions. Semantically, that's like breaking, by default, every time a C
> function returns an error code.

While I don't disagree with that, and I use a debugger which by default
does not pause on caught exceptions, I tend to run it configured to
pause on all thrown exceptions regardless.

This is because in the codebases I tend to work with, exceptions are
rare and unusual and generally indicative of a serious problem in either
the code or the input, and thus they ought to be investigated whenever
they happen, because they're not supposed to ever happen.

As a result, code that throws exceptions for other reasons irritates me,
and I try to avoid using it.

Even where I might normally run without that enabled, at some point I
find myself needing to track down a logged exception, so I turn it on,
and then get irritated if exceptions other than the one I was looking
for turn up. So again it's preferable to not have them happen unless
they're serious.

And of course there's the old adage about not using exceptions for
"normal" control flow (whatever normal means to your method).

Boost list run by bdawes at, gregod at, cpdaniel at, john at