From: Benjamin Kosnik Date: Thu, 4 Jul 2002 00:48:50 +0000 (+0000) Subject: re PR libstdc++/7057 (Operator== on hashtables doesn't appear to work correctly ... X-Git-Tag: releases/gcc-3.1.1~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a8c602da389ff422482e6351dfcf1015928760d;p=thirdparty%2Fgcc.git re PR libstdc++/7057 (Operator== on hashtables doesn't appear to work correctly (patch included)) 2002-07-03 Steev Wilcox PR libstdc++/7057 * include/ext/stl_hashtable.h: Fix. * testsuite/ext/hash_map.cc: New. From-SVN: r55232 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index fa61f6e5fdc4..786797830cd1 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2002-07-03 Steev Wilcox + + PR libstdc++/7057 + * include/ext/stl_hashtable.h: Fix. + * testsuite/ext/hash_map.cc: New. + +2002-07-03 Benjamin Kosnik + + PR libstdc++/7097 + * include/c/std_cwchar.h: Fix. + 2002-07-03 Jack Reeves Kenny Simpson Phil Edwards diff --git a/libstdc++-v3/include/ext/stl_hashtable.h b/libstdc++-v3/include/ext/stl_hashtable.h index 5ee49d815f7c..2bc8a2fcec0a 100644 --- a/libstdc++-v3/include/ext/stl_hashtable.h +++ b/libstdc++-v3/include/ext/stl_hashtable.h @@ -610,11 +610,28 @@ bool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, for (size_t __n = 0; __n < __ht1._M_buckets.size(); ++__n) { _Node* __cur1 = __ht1._M_buckets[__n]; _Node* __cur2 = __ht2._M_buckets[__n]; - for ( ; __cur1 && __cur2 && __cur1->_M_val == __cur2->_M_val; + // Check same length of lists + for ( ; __cur1 && __cur2; __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next) {} if (__cur1 || __cur2) return false; + // Now check one's elements are in the other + for (__cur1 = __ht1._M_buckets[__n] ; __cur1; __cur1 = __cur1->_M_next) + { + bool _found__cur1 = false; + for (_Node* __cur2 = __ht2._M_buckets[__n]; + __cur2; __cur2 = __cur2->_M_next) + { + if (__cur1->_M_val == __cur2->_M_val) + { + _found__cur1 = true; + break; + } + } + if (!_found__cur1) + return false; + } } return true; }