Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3659: warning when using boost::counting_iterator<int> and std::vector<int> on MSVC
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-06-04 11:28:23
#3659: warning when using boost::counting_iterator<int> and std::vector<int> on
MSVC
---------------------------+------------------------------------------------
Reporter: anonymous | Owner: dave
Type: Bugs | Status: closed
Milestone: Boost 1.42.0 | Component: iterator
Version: Boost 1.41.0 | Severity: Cosmetic
Resolution: wontfix | Keywords:
---------------------------+------------------------------------------------
Comment (by Sergey Mitsyn <svm at jinr.ru>):
The warning still doesn't go when the difference type is explicitly
specified instead of the default:
{{{
#include <boost/iterator/counting_iterator.hpp>
int main()
{
boost::counting_iterator<int, boost::use_default, int> a(0),
b(10);
a+=(b-a);
return 0;
}
}}}
the compiler complains with the following:
{{{
boost_1_43_0\boost\iterator\counting_iterator.hpp(139) : warning C4244:
'return' : conversion from '__int64' to 'int', possible loss of data
}}}
IMHO looks like the C-style cast to {{{ numeric_distance }}} forces the
difference to be intmax_t, and implicit conversion to return type {{{
Difference }}} invokes the warning.
Maybe it's OK to assume that if a user specifies the difference type
explicitly, he/she knows what he/she is doing and use static_cast to {{{
Difference }}}?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3659#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC