PR 54075 Fix hashtable::reserve
François Dumont
frs.dumont@gmail.com
Wed Jul 25 22:37:00 GMT 2012
Attached patch applied to trunk. I am building 4.7 branch to also apply
the patch to this branch.
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 guarantee that hashtable
state is consistent with hash policy state.
(_Hashtable<>::rehash): Likewise. Set _M_prev_resize to 0 to avoid
the hashtable to be shrinking 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.
François
On 07/25/2012 04:55 PM, Jonathan Wakely wrote:
> (CC gcc-patches)
>
> On 25 July 2012 10:26, François Dumont wrote:
>> 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.
> s/guaranty/guarantee/
>
>> (_Hashtable<>::rehash): Likewise. Set _M_prev_resize to 0 to avoid
>> the hashtable to be shrink on next insertion.
> s/to be shrink/shrinking/
>
>> * 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.
> OK with the changelog edits above.
>
>> I guess it will have to be apply to the 4.7 branch too, confirm please.
> Yes, I think so, it's a regression from 4.6.
>
> Thanks for dealing with it so quickly.
-------------- 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/3e597aea/attachment.bin>
More information about the Libstdc++
mailing list