Boost logo

Boost :

Subject: Re: [boost] [Contract] noexcept and custom contract violation handlers
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2012-09-02 15:40:16

2012/9/2 Dave Abrahams <dave_at_[hidden]>

> on Thu Aug 30 2012, Andrzej Krzemienski <> wrote:
> > Hi,
> > I have just realized that there is an interesting interaction between
> > "noexcept" and Contract Programming framework. Not only Lorenzo's
> library,
> > but even if contracts were a language feature. N3248 ("noexcept prevents
> > library validation",
> >
> > recommends that functions with any preconditions should not be declared
> > noexcept(true) in case someone wants to report precondition failures via
> > exceptions.
> This is bad advice and should be ignored. Exceptions and preconditions
> have no inherent relationship, exceptions are not a good tool for
> handling precondition failures, and nothing should be done to link them.

I agree in principle; however, N3248 provides one example that cannot be
that quickly dismissed: testing if your library defined (and verified)
enough preconditions.

Also, one other concern is that since Contract Programming framework
provides customization functions, like set_postcondition_broken, people
will likely choose to configure the library to throw on contract breakage.
They will define a cool exception type, like BrokenContract, and throw it.
If not for any other reason, then because languages like D do it; or
because they are afraid of std::terminate (more than they are afraid of
writing incorrect code). Although, you could say that in this case
termination from precondition breakage will be replaced with termination
from noexcept violation, which is what people deserve if they break


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