id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 5674,assertion failed in boost::range::copy_n(),farid@…,Neil Groves,"The program below fails on assert: {{{ #!cpp #include #include int main(int argc, char* argv[]) { int src[5] = { 1, 2, 3, 4, 5 }; int dst[5]; boost::copy_n(boost::make_iterator_range(src, src + 5), 5, dst); return 0; } }}} {{{ Assertion failed: n < static_cast(boost::distance(rng)), file boost_1_46_1/boost/range/algorithm_ext/copy_n.hpp, line 38 }}} Proposed patch: {{{ --- boost/range/algorithm_ext/copy_n.hpp +++ boost/range/algorithm_ext/copy_n.hpp @@ -30,12 +30,12 @@ /// /// \pre SinglePassRange is a model of the SinglePassRangeConcept /// \pre OutputIterator is a model of the OutputIteratorConcept -/// \pre 0 <= n < distance(rng) +/// \pre 0 <= n <= distance(rng) template< class SinglePassRange, class Size, class OutputIterator > inline OutputIterator copy_n(const SinglePassRange& rng, Size n, OutputIterator out) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_ASSERT( n < static_cast(boost::distance(rng)) ); + BOOST_ASSERT( n <= static_cast(boost::distance(rng)) ); BOOST_ASSERT( n >= static_cast(0) ); BOOST_DEDUCED_TYPENAME range_iterator::type source = boost::begin(rng); }}} ",Patches,closed,Boost 1.50.0,range,Boost 1.46.1,Problem,fixed,copy_n,