[Boost-bugs] [Boost C++ Libraries] #8464: boost::asio::read_size_helper non consistent with boost::asio::basic_streambuf::read_size_helper

Subject: [Boost-bugs] [Boost C++ Libraries] #8464: boost::asio::read_size_helper non consistent with boost::asio::basic_streambuf::read_size_helper
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-04-19 18:29:47


#8464: boost::asio::read_size_helper non consistent with
boost::asio::basic_streambuf::read_size_helper
---------------------------------------------------+------------------------
 Reporter: Thomas Riccardi <riccardi@…> | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
---------------------------------------------------+------------------------
 In boost 1.53.0 and svn trunk r83967 (current HEAD) in
 asio/basic_streambuf.hpp the function ''read_size_helper'' is defined two
 times:

 1/ in ''basic_streambuf'' class l344:

 {{{
   // Helper function to get the preferred size for reading data.
   friend std::size_t read_size_helper(
       basic_streambuf& sb, std::size_t max_size)
   {
     return std::min<std::size_t>(
         std::max<std::size_t>(512, sb.buffer_.capacity() - sb.size()),
         std::min<std::size_t>(max_size, sb.max_size() - sb.size()));
   }
 }}}

 2/ as a free function l356:

 {{{
 // Helper function to get the preferred size for reading data. Used for
 any
 // user-provided specialisations of basic_streambuf.
 template <typename Allocator>
 inline std::size_t read_size_helper(
     basic_streambuf<Allocator>& sb, std::size_t max_size)
 {
   return std::min<std::size_t>(512,
       std::min<std::size_t>(max_size, sb.max_size() - sb.size()));
 }
 }}}


 They don't compute the same value:

 1/ returns a number between 512 and max_size if max_size > 512 (which
 happens in several locations in the code), otherwise returns max_size.

 2/ returns at most 512.


 Shouldn't they return the same thing?
 It seems to me the intended result is 1/.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8464>
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:12 UTC