public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14716] New: hash_set doesn't work for pointers other than char*
@ 2004-03-24 12:51 mgd at technosis dot de
  2004-03-24 13:16 ` [Bug c++/14716] " pcarlini at suse dot de
  0 siblings, 1 reply; 2+ messages in thread
From: mgd at technosis dot de @ 2004-03-24 12:51 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/14716] hash_set doesn't work for pointers other than char*
  2004-03-24 12:51 [Bug c++/14716] New: hash_set doesn't work for pointers other than char* mgd at technosis dot de
@ 2004-03-24 13:16 ` pcarlini at suse dot de
  0 siblings, 0 replies; 2+ messages in thread
From: pcarlini at suse dot de @ 2004-03-24 13:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-03-24 13:16 -------
This is a well known issue: for types not present in ext/stl_hash_fun.h you
must provide an appropriate specialization of struct hash.

*** This bug has been marked as a duplicate of 13342 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-03-24 13:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-24 12:51 [Bug c++/14716] New: hash_set doesn't work for pointers other than char* mgd at technosis dot de
2004-03-24 13:16 ` [Bug c++/14716] " pcarlini at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).