Re: [Boost-bugs] [Boost C++ Libraries] #7739: Divide by zero error in hash_map.hpp

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7739: Divide by zero error in hash_map.hpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-11-28 05:29:56


#7739: Divide by zero error in hash_map.hpp
-------------------------------------------------+--------------------------
  Reporter: Gaurav Gupta <g.gupta@…> | Owner: chris_kohlhoff
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: asio
   Version: Boost 1.52.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------------------------+--------------------------

Comment (by Gaurav Gupta <g.gupta@…>):

 Replying to [comment:1 steven_watanabe]:
> This is not a bug, as num_buckets cannot be zero in the first place.

 Its True, num_buckets canot be zero, but this check is safe here, as many
 tools (like Prevent )report this as '''DIVIDE By Zero''' error.

 Also In my patch , I have provided fix at two places, other is in
 following code snippet.

 {{{
 void erase(iterator it)
   {
     BOOST_ASSERT(it != values_.end());

     '''size_t bucket = calculate_hash_value(it->first) % num_buckets_;'''
     bool is_first = (it == buckets_[bucket].first);
     bool is_last = (it == buckets_[bucket].last);

     ----- SOME CODE ------

     values_erase(it);
     --size_;
   }
 }}}

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