]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/52309 ([c++0x] unordered_set illegally requires value_type::operator!=)
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 20 Feb 2012 11:31:01 +0000 (11:31 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 20 Feb 2012 11:31:01 +0000 (11:31 +0000)
2012-02-20  Paolo Carlini  <paolo.carlini@oracle.com>

PR libstdc++/52309
* include/bits/hashtable_policy.h (_Equality_base<, true,>::
     _M_equal(const _Hashtable&)): Compare values with operator==.
* testsuite/23_containers/unordered_set/operators/52309.cc: New.

From-SVN: r184389

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/hashtable_policy.h
libstdc++-v3/testsuite/23_containers/unordered_set/operators/52309.cc [new file with mode: 0644]

index 5dc5c06444abba1f54a145e0efcab73ad38062ba..0d46aa3e1cbdb0281c263ac6d3a238fe0256c0c5 100644 (file)
@@ -1,3 +1,10 @@
+2012-02-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR libstdc++/52309
+       * include/bits/hashtable_policy.h (_Equality_base<, true,>::
+       _M_equal(const _Hashtable&)): Compare values with operator==.
+       * testsuite/23_containers/unordered_set/operators/52309.cc: New.
+
 2012-02-01  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR libstdc++/51795
index f6e187616ee2c39d7bf7390a371796918792ee74..ec3a29c515a8b06280467748158d0551b8533b44 100644 (file)
@@ -887,7 +887,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       for (auto __itx = __this->begin(); __itx != __this->end(); ++__itx)
        {
          const auto __ity = __other.find(_ExtractKey()(*__itx));
-         if (__ity == __other.end() || *__ity != *__itx)
+         if (__ity == __other.end() || !bool(*__ity == *__itx))
            return false;
        }
       return true;
@@ -925,7 +925,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        for (_Uiterator __it1 = __first1; __it1 != __last1; ++__it1)
          {
            _Uiterator __tmp =  __first1;
-           while (__tmp != __it1 && !(*__tmp == *__it1))
+           while (__tmp != __it1 && !bool(*__tmp == *__it1))
              ++__tmp;
 
            // We've seen this one before.
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/operators/52309.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/operators/52309.cc
new file mode 100644 (file)
index 0000000..5b16f0b
--- /dev/null
@@ -0,0 +1,28 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2012 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <unordered_set>
+
+// libstdc++/52309
+struct value {};
+struct hash { std::size_t operator()(const value&) const; };
+bool operator==(value const&, value const&);
+std::unordered_set<value, hash> set;
+bool z = (set == set);