Boost logo

Boost :

Subject: Re: [boost] Looking for thoughts on a new smart pointer: shared_ptr_nonnull
From: Nevin Liber (nevin_at_[hidden])
Date: 2013-10-09 11:18:52


On 9 October 2013 01:31, Thorsten Ottosen <thorsten.ottosen_at_[hidden]>wrote:

You seem to be completely obsessed by the point that a precondition or
> invariant violation must always be checked by compiled-away assertions.
>

You seem completely obsessed to call it a precondition or invariant
violation. Why? All you have to do is make it defined behavior in your
library; then it isn't a bug and apparently everyone will be happy.

> Your argument is that there is a bug in the program and that you should
> terminate anyway. Sadly, must programs have bugs, but we use them anyway.

Most programs don't have detectable (by code) bugs.

Just make sure your engineers, business owners and clients understand the
risk they are taking on.

> In practice it matters for some to avoid UB.

I thought in practice it matters to avoid bugs.

> It's a major benefit of using Java or C#.

And yet programming bugs happen in those languages too.

The great thing about UB is that you can tell people "there be dragons;
don't go there", and you can even add checks in some builds to detect such
bugs. If the behavior is well defined, you can't do that, because a
programmer could be legitimately calling it for that behavior.

-- 
 Nevin ":-)" Liber  <mailto:nevin_at_[hidden]>  (847) 691-1404

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk