This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/23244] __gnu_cxx::hash_map inconsistent iterator behavior
- From: "chris at bubblescope dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Aug 2005 08:29:58 -0000
- Subject: [Bug libstdc++/23244] __gnu_cxx::hash_map inconsistent iterator behavior
- References: <20050805025731.23244.jzampier@gmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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