[Bug c++/14716] New: hash_set doesn't work for pointers other than char*

mgd at technosis dot de gcc-bugzilla@gcc.gnu.org
Wed Mar 24 12:51:00 GMT 2004


Hi ! 
 
Compiler: gcc 3.3.3 
OS: SuSE Linux 2.4.21-199-default i686 i386 GNU/Linux 
 
gcc was built using 
../gcc-3.3.3/configure 
--with-gcc-version-trigger=/home/mgd/src/gcc-3.3.3/gcc/version.c 
--host=i686-pc-linux-gnu --norecursion  
 
Find below a small program. It will be compiled using 
g++ -Wall set-sample.cpp 
which results in no complaints whatsoever. 
 
When I do a global replace 'char' with 'long' or any 
other integral type I get a couple of errors (below 
the source file). 
 
I have not added set-sample.ii.gz since this is still over 
100k but I'm happy to mail it to whoever asks for it. 
 
set-sample.cpp: 
---snip---snip---snip---snip---snip---snip---snip---snip---snip--- 
#include <ext/hash_set> 
 
typedef __gnu_cxx::hash_set<const char*>	myset; 
 
void lookup(const myset& Set, const char* word) 
{ 
  myset::const_iterator it 
    = Set.find(word); 
} 
 
int main() 
{ 
  myset Set; 
  char*	pMango = new char(); 
  Set.insert(pMango); 
 
  char*	pDurian = new char(); 
  lookup(Set, pMango); 
  lookup(Set, pDurian); 
} 
---snap---snap---snap---snap---snap---snap---snap---snap---snap--- 
 
Error after replacing char with long: 
---snip---snip---snip---snip---snip---snip---snip---snip---snip--- 
usr/local/include/c++/3.3.3/ext/stl_hashtable.h: In member function `size_t 
   __gnu_cxx::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, 
   _Alloc>::_M_bkt_num_key(const _Key&, unsigned int) const [with _Val = const 
   long int*, _Key = const long int*, _HashFcn = __gnu_cxx::hash<const long 
   int*>, _ExtractKey = std::_Identity<const long int*>, _EqualKey = 
   std::equal_to<const long int*>, _Alloc = std::allocator<const long int*>]': 
/usr/local/include/c++/3.3.3/ext/stl_hashtable.h:504:   instantiated from 
`size_t __gnu_cxx::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, 
_Alloc>::_M_bkt_num_key(const _Key&) const [with _Val = const long int*, _Key 
= const long int*, _HashFcn = __gnu_cxx::hash<const long int*>, _ExtractKey = 
std::_Identity<const long int*>, _EqualKey = std::equal_to<const long int*>, 
_Alloc = std::allocator<const long int*>]' 
/usr/local/include/c++/3.3.3/ext/stl_hashtable.h:454:   instantiated from 
`__gnu_cxx::_Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, 
_EqualKey, _Alloc> __gnu_cxx::hashtable<_Val, _Key, _HashFcn, _ExtractKey, 
_EqualKey, _Alloc>::find(const _Key&) const [with _Val = const long int*, _Key 
= const long int*, _HashFcn = __gnu_cxx::hash<const long int*>, _ExtractKey = 
std::_Identity<const long int*>, _EqualKey = std::equal_to<const long int*>, 
_Alloc = std::allocator<const long int*>]' 
/usr/local/include/c++/3.3.3/ext/hash_set:188:   instantiated from `typename 
__gnu_cxx::hashtable<_Value, _Value, _HashFcn, std::_Identity<_Value>, 
_EqualKey, _Alloc>::const_iterator __gnu_cxx::hash_set<_Value, _HashFcn, 
_EqualKey, _Alloc>::find(typename __gnu_cxx::hashtable<_Value, _Value, 
_HashFcn, std::_Identity<_Value>, _EqualKey, _Alloc>::key_type&) const [with 
_Value = const long int*, _HashFcn = __gnu_cxx::hash<const long int*>, 
_EqualKey = std::equal_to<const long int*>, _Alloc = std::allocator<const long 
int*>]' 
set-sample.cpp:12:   instantiated from here 
/usr/local/include/c++/3.3.3/ext/stl_hashtable.h:514: error: no match for call 
   to `(const __gnu_cxx::hash<const long int*>) (const long int* const&)' 
---snap---snap---snap---snap---snap---snap---snap---snap---snap--- 
 
The weekly snapshot gcc-3.4-20040317 basically behaves the same 
in that the error is differently formatted. 
 
Best, 
Michael

-- 
           Summary: hash_set doesn't work for pointers other than char*
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mgd at technosis dot de
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14716



More information about the Gcc-bugs mailing list