Closed GoogleCodeExporter closed 9 years ago
As the comment in m4/stl_hash.m4 says, "I've seen unexplainable unordered_map
bugs with -O2 on older gcc's." So I purposefully still use the __gnu_cxx hash,
rather than the tr1 hash, with gcc 4.1.2.
Both hashes are available in 4.1.2, so I'm not sure exactly what the problem is
that you're reporting. Do you have code that doesn't work?
Original comment by csilv...@gmail.com
on 6 Dec 2010 at 8:24
sorry, i did not give any attentions to the comment.
when i migrate to 1.9, it complains about __gnu_cxx. it seems our code's old
version
sparsehash is using the tr1 namespace.
maybe someone manually edit the sparseconfig.h to force using tr1. :)
Original comment by james.fa...@gmail.com
on 7 Dec 2010 at 3:29
Hmm, what is the exact complaint you're seeing? Can you give a specific
example of a compile command you try to run, and the errors you get in response?
Original comment by csilv...@gmail.com
on 7 Dec 2010 at 4:24
here it is:
/usr/local/include/google/sparsehash/hashtable-common.h:65: error:
‘operator()’ is not a member of ‘__gnu_cxx::hash<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >’
our code does not provide a hash function for std::string in __gnu_cxx,
it just force sparsehash to use tr1 instead.
Original comment by james.fa...@gmail.com
on 7 Dec 2010 at 6:37
Ah, I see what the problem is. __gnu_cxx::hash<> does not provide a default
hash for string, though it does for char*. tr1::hash<> is the other way
around: it does provide hash<string>, but not hash<char*>. The problem isn't
the fact it's in __gnu_cxx, the problem is you're depending on the system to
provide a hash function for you which it's not.
I'm closing this as NotABug since it's really not sparsehash's responsibility
to deal with hash functions at all. The approach you're using now, of forcing
tr1::hash<>, is fine. Another approach would be to just define your own hash
function, so you don't have to worry about what the system provides.
Original comment by csilv...@gmail.com
on 7 Dec 2010 at 6:56
/home/zhangchi/local/include/sparsehash/sparse_hash_map:249:75: instantiated
from 'google::sparse_hash_map<Key, T, HashFcn, EqualKey, Alloc>::iterator
google::sparse_hash_map<Key, T, HashFcn, EqualKey,
Alloc>::find(google::sparse_hash_map<Key, T, HashFcn, EqualKey,
Alloc>::key_type&) [with Key = long long unsigned int, T = bool, HashFcn =
__gnu_cxx::hash<long long unsigned int>, EqualKey = std::equal_to<long long
unsigned int>, Alloc = google::libc_allocator_with_realloc<std::pair<const long
long unsigned int, bool> >, google::sparse_hash_map<Key, T, HashFcn, EqualKey,
Alloc>::iterator = google::sparse_hashtable_iterator<std::pair<const long long
unsigned int, bool>, long long unsigned int, __gnu_cxx::hash<long long unsigned
int>, google::sparse_hash_map<long long unsigned int, bool>::SelectKey,
google::sparse_hash_map<long long unsigned int, bool>::SetKey,
std::equal_to<long long unsigned int>,
google::libc_allocator_with_realloc<std::pair<const long long unsigned int,
bool> > >, google::sparse_hash_map<Key, T, HashFcn, EqualKey, Alloc>::key_type
= long long unsigned int]'
GenericNodeMemWrapper.cpp:960:55: instantiated from here
/home/zhangchi/local/include/sparsehash/internal/hashtable-common.h:250:62:
error: 'operator()' is not a member of
'google::sparsehash_internal::sh_hashtable_settings<long long unsigned int,
__gnu_cxx::hash<long long unsigned int>, long unsigned int, 4>::hasher'
Original comment by hewm2...@gmail.com
on 23 Jul 2013 at 5:59
Original issue reported on code.google.com by
james.fa...@gmail.com
on 6 Dec 2010 at 10:56