Boost logo

Boost :

Subject: Re: [boost] warning policy issue
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2009-11-26 12:55:49

> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On
Behalf Of
> Robert Ramey
> Sent: Thursday, November 26, 2009 5:32 PM
> To: boost_at_[hidden]
> Subject: [boost] warning policy issue
> On page
> it's suggested that the following warning at level 4 can be eliminated with
> a static cast
> warning C4244: 'argument' : conversion from <type1> to <type2> possible
> loss of data
> I've found this not to be true at least with msvc 7.1

With MVSC Microsoft Visual Studio 2008
Version 9.0.21022.8 RTM Microsoft .NET Framework Version 3.5 SP1

if I write

    long x = 1234567890;
    short y = x;

I get a c4244 warning, but adding static_cast

    long x = 1234567890;
    short y = static_cast<short>(x);

I don't get a warning (even if I don't get the value I might be expecting ;-)

My recollection (dim!) is that 7.1 works the same.

Are you quite sure you are casting to the right type?

Or is suppressing the line of least resistance (sounds a bit dodgy to me).


Paul A. Bristow
Prizet Farmhouse
Kendal, UK   LA8 8AB
+44 1539 561830, mobile +44 7714330204

Boost list run by bdawes at, gregod at, cpdaniel at, john at