Subject: Re: [boost] Current Guidance on Compiler Warnings?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2018-11-24 23:11:26
On Sat, Nov 24, 2018 at 11:18 AM Robert Ramey via Boost <
> 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.
In C and C++ operands are not promoted to the same type. If you have:
short x, y;
the type of the expression x+y is not short, it is int.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk