Passing a boost::unordered_set as the result map to boost::split
Anyone here know the answer to this question? http://stackoverflow.com/questions/3981123/passing-a-boostunordered-set-as-t... Thanks, Jeremy
On 20 October 2010 21:07, Jeremy Stribling
Anyone here know the answer to this question?
http://stackoverflow.com/questions/3981123/passing-a-boostunordered-set-as-t...
The problem is in this code from boost/unordered/detail/unique.hpp: key_type const& k = extractor::extract(*i); std::size_t hash_value = this->hash_function()(k); bucket_ptr bucket = this->bucket_ptr_from_hash(hash_value); node_ptr pos = this->find_iterator(bucket, k); It seems that the dereferenced iterator value is destroyed before hash_function is called. I was under the impression that it was safe to use that reference until the next time the iterator is used. If that's right, then it's a bug in split, if that's wrong then it's a bug in unordered_set. The attached patch is a workaround/fix. Daniel
On 21 October 2010 00:46, Daniel James
It seems that the dereferenced iterator value is destroyed before hash_function is called. I was under the impression that it was safe to use that reference until the next time the iterator is used. If that's right, then it's a bug in split, if that's wrong then it's a bug in unordered_set. The attached patch is a workaround/fix.
I've looked into this a little more, and it is a bug in boost::unordered_set. I'll check a fix into trunk this evening (I need to write some tests first). Hopefully, it will be in time for 1.45. Daniel
participants (2)
-
Daniel James
-
Jeremy Stribling