Boost logo

Boost Users :

Subject: Re: [Boost-users] Passing a boost::unordered_set as the result map to boost::split
From: Daniel James (dnljms_at_[hidden])
Date: 2010-10-20 19:46:00


On 20 October 2010 21:07, Jeremy Stribling <nedmike_at_[hidden]> wrote:
> Anyone here know the answer to this question?
>
> http://stackoverflow.com/questions/3981123/passing-a-boostunordered-set-as-the-result-map-to-boostsplit

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




Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net