Boost logo

Boost :

Subject: Re: [boost] Current Guidance on Compiler Warnings?
From: degski (degski_at_[hidden])
Date: 2018-11-26 12:44:08


On Mon, 26 Nov 2018 at 08:38, Emil Dotchevski via Boost <
boost_at_[hidden]> wrote:

> The reason is that they have the wrong mindset when approaching the
> problem.
>
> They think: I get a warning, because the compiler doesn't know that this
> signed value is always positive, but I know that it is, so I'm going to
> cast, to tell the compiler that I know what I'm doing.
>
> A better reasoning is: I'm converting a signed value to unsigned value,
> which will not be correct if the signed value is negative. With this in
> mind, you'll notice that the cast is utterly useless in catching the actual
> error the compiler is warning you about.
>

+1, the above summarizes the issue quite nicely, I think.

degski

-- 
*“If something cannot go on forever, it will stop" - Herbert Stein*

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