Boost logo

Boost :

Subject: Re: [boost] Current Guidance on Compiler Warnings?
From: Robert Ramey (ramey_at_[hidden])
Date: 2018-11-24 19:17:44


On 11/24/18 7:52 AM, Peter Dimov via Boost wrote:
> Daniela Engert wrote:

> Making it an error would be a useful first step towards making it work
> correctly. :-)
>
> (It's perfectly possible to compare a value in [INT_MIN, INT_MAX] with a
> value in [0, UINT_MAX], it's just that the standard says op< needs to do
> the wrong thing.)

I appologize in advance for perhaps hijacking the thread, but I can't
restrain myself from the opportunity to plug the most recent addition
to the boost libaries - safe_numerics.

C/C++ "arithmetic" is not really arithmetic. That is, results of the
arithmetic operations are not guaranteed to map to their counterparts in
the arithmetic of integers. The C/C++ rules for promoting operands to
the same type can and do introduce errors. Then the application of
operations defined in terms to unbounded integers to the bounded
integers we use in our programs can and do return incorrect results.
Warnings like the above can definitely help, but can't guarantee that
the problem does not occur. It is not possible to prove that these
problems cannot occur by visual inspection. We're living a lie.

So I invite all parties who write programs which much function as
written to take a look a the boost safe numerics library. I think
you'll find it interesting.

Robert Ramey


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