id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 6722,Incorrect behaviour of boost::iostreams::filtering_stream with boost::iterator_range,vadik.stepanov@…,Jonathan Turkanis,"Please consider the following code: {{{ #include #include #include template std::string read_to_string(Stream& stream) { std::ostringstream destStream; destStream << stream.rdbuf(); return destStream.str(); } void main() { std::istringstream sourceStream(""123""); std::istream_iterator begin(sourceStream); std::istream_iterator end; auto range = boost::make_iterator_range(begin, end); boost::iostreams::filtering_stream sourceFilteringStream; sourceFilteringStream.push(range, 1); std::string output = read_to_string(sourceFilteringStream); BOOST_ASSERT(""123"" == output); } }}} After each char from ""sourceStream"" it produces additional garbage char in ""output"" and triggers the assert (at least in VS10). I've traced it to this code in boost/iostreams/detail/adapter/range_adapter.hpp: {{{ template<> struct range_adapter_impl { template static std::streamsize read (Iter& cur, Iter& last, Ch* s,std::streamsize n) { std::streamsize rem = n; // No. of chars remaining. while (cur != last && rem-- > 0) *s++ = *cur++; return n - rem != 0 ? n - rem : -1; } ... }}} ""rem"" becomes -1 after the end of the while-loop and the return value after reading 1 char is 2.",Bugs,new,To Be Determined,iostreams,Boost 1.48.0,Problem,,,jeffrey.hellrung