Bug 52309 - [c++0x] unordered_set illegally requires value_type::operator!=
Summary: [c++0x] unordered_set illegally requires value_type::operator!=
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.3
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-19 16:24 UTC by Roman Kononov
Modified: 2012-02-20 11:31 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.5.4, 4.6.3, 4.7.0
Last reconfirmed: 2012-02-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Kononov 2012-02-19 16:24:03 UTC
$ cat test.cpp 
#include <unordered_set>
struct value {};
struct hash { std::size_t operator()(value const&)const; };
bool operator==(value const&,value const&);
std::unordered_set<value,hash> set;
bool z=(set==set);

$ g++ -std=c++0x -c test.cpp 2>&1 | egrep error
...../include/c++/4.7.0/bits/hashtable_policy.h:1116:4: error: no match for ‘operator!=’ in ‘__ity.std::__detail::_Node_const_iterator<_Value, __constant_iterators, __cache>::operator*<value, true, true>() != __itx.std::__detail::_Node_const_iterator<_Value, __constant_iterators, __cache>::operator*<value, true, true>()’

"set==set" needs operator!=(value,value).
 
The "value" type is EqualityComparable and looks good for unordered_set. (17.6.3.1, 23.2.1, 23.2.5/2 and 23.2.5/11) 

All other associative unordered containers do not need value_type::operator!=(). Only unordered_set requires it.
Comment 1 Paolo Carlini 2012-02-19 16:54:37 UTC
Oops, but seems trivial to fix.
Comment 2 paolo@gcc.gnu.org 2012-02-20 11:11:44 UTC
Author: paolo
Date: Mon Feb 20 11:11:39 2012
New Revision: 184388

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184388
Log:
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.


Added:
    trunk/libstdc++-v3/testsuite/23_containers/unordered_set/operators/52309.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/hashtable_policy.h
Comment 3 paolo@gcc.gnu.org 2012-02-20 11:31:07 UTC
Author: paolo
Date: Mon Feb 20 11:31:01 2012
New Revision: 184389

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184389
Log:
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.


Added:
    branches/gcc-4_6-branch/libstdc++-v3/testsuite/23_containers/unordered_set/operators/52309.cc
Modified:
    branches/gcc-4_6-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_6-branch/libstdc++-v3/include/bits/hashtable_policy.h
Comment 4 Paolo Carlini 2012-02-20 11:31:56 UTC
Fixed mainline and 4.6.3.