This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/23244] __gnu_cxx::hash_map inconsistent iterator behavior


------- Additional Comments From chris at bubblescope dot net  2005-08-05 08:29 -------
While it doesn't fix your bug, if you want a hash_map I'd advise looking at tr1/unordered_map, which 
I'd expect to work better. I think however you'll find that all implementations of hash_map strictly tell 
you to not change how the indexing data member is changed, so I suspect this is generally in the world 
of undefined behaviour anyway (although like you say, fixing the undefined behaviour wouldn't be 
easy). For example, while you might get away with this in map or set, if you then did anything (like add 
new or erase existing elements), things blow up horribly.

This would also be very hard to "fix", even if we wanted to, because at the moment when we reach the 
end of one bucket there is no way of knowing which bucket we are in without hashing the current value. 
We would probably have the either redesign the buckets so the end of each pointed to the beginning of 
the next (which might actually not be a totally bad idea, but would require some major redesign) or 
doubling (at least) the size of the iterators, which I doubt will happen.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23244


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]