|
Boost : |
Subject: Re: [boost] a safe integer library
From: Robert Ramey (ramey_at_[hidden])
Date: 2015-12-10 14:04:54
On 12/10/15 10:44 AM, Phil Endecott wrote:
> Hi Robert,
>
> Robert Ramey wrote:
>> I've also made a proposal for the C++ Standards committee to include a
>> simplified version of this library as part of he C++ standard.
>>
>> You can see the proposal at
>> http://www.rrsd.com/software_development/safe_numerics/proposal.pdf
>
> I've had a quick look at this PDF. Some random thoughts:
>
> - The "safe integer" solution that I've heard most about is Miscrosoft's,
> which I don't think is one of those that you cite in your references.
>
> - At the top of page 3 of your PDF there's an example where you square an
> int8_t and assign the result to an int8_t, and say this can't overflow.
> Either I'm missing something (which is quite possible!) or you meant to
> assign to a wider result type.
damn - you're right. The multiplication can't overflow, but the
subsequent assignment can. I'll change this.
> - I suspect that in my code, the consequences of an exception that I
> hadn't considered could be just as bad as an overflow that I'd not
> considered!
LOL - Then this library is not for you! Actually, I'm guessing you have
a lot of company here. I proposed a talk at CPPcon on this and there
was not interest among the reviewers. It's hard to tell, but it seemed
that it was just a not a problem.
Another sentiment I've seen expressed is that this is only appropriate
for less skilled programmers who don't really know about how to write
code. In the documentation at www.blincubator.com I've tried to dispell
the nothing that this can be addressed in an ad hoc manner.
To me this is a 30 year festering carbuncle on the face of C++/C. For
the language to permit the writing of an arithmetical expression and to
permit it to fail silently, is a recipe for disaster which are are
suffering from on a daily basis. The amazing thing to me is that all
languages have have this problem - even those which are interpreted!!!
How have computer engineers been able to ignore/forget what the
fundamental purpose is about - to provide correct answers. We're using
C++ to write code for self driving cars - and no one cares about this.
I can't express how disheartening to me this is.
BUT now we have a realistic solution!!!. I believe this is a practical,
correct, elegant alternative which we can add on to C++ via a library
such as this. Then C++ can stand alone not only as the way to create
the most efficient programs but the most correct one as well. There
will be no serious competitor.
And this is testement to the foresight, vision and genius of our
community leaders. This library depends upon constexpr, operator
overloading and other (recent) C++ features. I believe that C++/14 is
going to usher in a whole new err for computation.
Now if could only get a utf8 codecvt facet which works.
Robert Ramey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk