This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/3552: missing hash function for std::string
- To: gcc-gnats at gcc dot gnu dot org, debian-gcc at lists dot debian dot org
- Subject: libstdc++/3552: missing hash function for std::string
- From: Matthias Klose <doko at klose dot in-berlin dot de>
- Date: Wed, 04 Jul 2001 00:16:38 +0200
- Reply-To: 87063-quiet at bugs dot debian dot org
>Number: 3552
>Category: libstdc++
>Synopsis: missing hash function for std::string
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Tue Jul 03 15:26:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Goswin Brederlow <goswin.brederlow@student.uni-tuebingen.de>
>Release: 3.0 (Debian GNU/Linux)
>Organization:
The Debian project
>Environment:
System: Debian GNU/Linux (testing/unstable)
Architecture: i686
host: i386-linux
build: i386-linux
target: i386-linux
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Description:
[ Reported to the Debian BTS as report #87063.
Please CC 87063-quiet@bugs.debian.org on replies.
Log of report can be found at http://bugs.debian.org/87063 ]
The STL hash_map does not work with strings. This is because no
hash<string> spezialisation is defined. The code for char* should be
used for strings also.
Heres a testcase:
----------------------------------------------------------------------
#include <ext/hash_map>
#include <string>
using namespace std;
int main() {
hash_map<string, int> myHashMap;
myHashMap["Hallo"] = 42;
}
----------------------------------------------------------------------
[commented by Laurent Bonnaud <Laurent.Bonnaud@inpg.fr>:]
This one is clearly a bug. In the Stroustrup book v3 (not the
definitive reference, but it's the closest thing I have) §17.6.1
explicitely uses a hash_map<string, int> class. Furthermore, §17.6.2.3
discusses about hashing strings.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: