PR 54075 Fix hashtable::reserve

François Dumont frs.dumont@gmail.com
Wed Jul 25 14:55:00 GMT 2012


Hi

     Here is a patch proposal for PR 54075. I also took the occasion to 
fix something that has been delay so far which is usage of std::max to 
get the number of buckets to use. The problem of using std::max when 
using the hash policy is that the hashtable might be using a number of 
buckets inconsistent with the hash policy.

2012-07-25  François Dumont  <fdumont@gcc.gnu.org>

     PR libstdc++/54075
     * include/bits/hashtable.h
     (_Hashtable<>::_Hashtable(_InputIterator, _InputIterator,
     size_type, ...): Remove std::max usage to guaranty that hashtable
     state is consistent with hash policy state.
     (_Hashtable<>::rehash): Likewise. Set _M_prev_resize to 0 to avoid
     the hashtable to be shrink on next insertion.
     * testsuite/23_containers/unordered_set/modifiers/reserve.cc: New.
     * testsuite/23_containers/unordered_multiset/modifiers/reserve.cc: New.
     * testsuite/23_containers/unordered_map/modifiers/reserve.cc: New.
     * testsuite/23_containers/unordered_multimap/modifiers/reserve.cc: New.

     Tested under Linux x86_64.

     I guess it will have to be apply to the 4.7 branch too, confirm please.

François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashtable.patch
Type: text/x-patch
Size: 8377 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20120725/1ea83ed7/attachment.bin>


More information about the Libstdc++ mailing list