Subject: [Boost-bugs] [Boost C++ Libraries] #5162: boost::iterator_range< T* > is unsafe
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-02-04 15:14:28
#5162: boost::iterator_range< T* > is unsafe
------------------------------------+---------------------------------------
Reporter: nicos@⦠| Owner: neilgroves
Type: Bugs | Status: new
Milestone: To Be Determined | Component: range
Version: Boost 1.45.0 | Severity: Problem
Keywords: |
------------------------------------+---------------------------------------
The following code compiles and does not generate any warning:
{{{
#include <boost/range/iterator_range.hpp>
int main()
{
double v[] = { 1.0,2.0,3.0 };
boost::iterator_range<float *> r = boost::make_iterator_range( v );
}
}}}
The culprits are adl_begin, adl_end, as in this case, they perform a
C-style cast from double* to float*:
{{{
template<class IteratorT>
struct iterator_range_impl {
template< class ForwardRange >
static IteratorT adl_begin( ForwardRange& r )
{
return IteratorT( boost::begin( r ) );
}
template< class ForwardRange >
static IteratorT adl_end( ForwardRange& r )
{
return IteratorT( boost::end( r ) );
}
};
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5162> 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:05 UTC