|
Boost : |
Subject: Re: [boost] Official warnings policy?
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2009-11-12 10:18:24
> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On
Behalf Of
> John Maddock
> Sent: Thursday, November 12, 2009 1:04 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] Official warnings policy?
> Delving into this a bit deeper, I believe the warning is correct, and cannot
> / should not be fixed, to recap we have:
>
> d:\data\boost\trunk\boost/variant/variant.hpp(1297) : warning C4244:
> 'argument' : conversion from 'const int' to 'const short', possible loss of
> data
<snip>
> The code calls Variant's converting-assignment operator, and Boost.Variant
> internally decides what type to convert the argument to and makes the
> assignment. In this case the user *should* see a warning to be alerted to
> the fact that the internal conversion results in loss of precision (likewise
> they would see an error in this location if there is no suitable
> conversion).
>
> I notice that the code in question has a comment to this effect:
>
> // NOTE TO USER :
> // Compile error here indicates one of the source variant's types
> // cannot be unambiguously converted to the destination variant's
> // types (or that no conversion exists).
>
> But perhaps we should add a similar note about compiler warnings?
Yes.
If the intention (boring) of the test is to provide an unsigned short int '58US'
or static_cast<unsigned short int>(58), then there should not be a warning,
but I agree that it is probably intended (more interestingly) to provide an
unsigned int (58) and demonstrate that this will involve loss of precision and
*will* give a warning.
But it does need a comment.
Paul
--- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk