Boost logo

Boost :

Subject: Re: [boost] Current Guidance on Compiler Warnings?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2018-11-28 00:56:12


On Tue, Nov 27, 2018 at 3:44 PM Gavin Lambert via Boost <
boost_at_[hidden]> wrote:
> As should hopefully be obvious, implicit narrowing conversions are never
> a good idea.

short f();

short x = f();
short y = x+1; //Implicit conversion from int to short.

Do you think the compiler should warn in this case? Is the version below
better? Safer?

short y = static_cast<short>(x+1);


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