public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/3552: missing hash function for std::string
@ 2002-05-08 11:46 Phil Edwards
0 siblings, 0 replies; 9+ messages in thread
From: Phil Edwards @ 2002-05-08 11:46 UTC (permalink / raw)
To: gdr; +Cc: gcc-prs
The following reply was made to PR libstdc++/3552; it has been noted by GNATS.
From: Phil Edwards <phil@jaj.com>
To: Goswin Brederlow <goswin.brederlow@student.uni-tuebingen.de>
Cc: Vadim Ogranovich <vograno@arbitrade.com>,
"'gcc-gnats@gcc.gnu.org'" <gcc-gnats@gcc.gnu.org>,
"'Laurent.Bonnaud@inpg.fr'" <Laurent.Bonnaud@inpg.fr>,
"'87063-quiet@bugs.debian.org'" <87063-quiet@bugs.debian.org>,
"'gcc-bugs@gcc.gnu.org'" <gcc-bugs@gcc.gnu.org>
Subject: Re: libstdc++/3552: missing hash function for std::string
Date: Wed, 8 May 2002 14:38:48 -0400
On Wed, May 08, 2002 at 07:01:45PM +0200, Goswin Brederlow wrote:
> > Yes. How can we possibly guess what a good hash function would be for
> > arbitrary strings? Efficiency of hashing is extremely dependant on the
> > data being hashed. You need to write one that's appropriate for your data;
> > this will involve multiple experiments.
> >
> > There is std::collate::hash() for char*'s, but this is essentially a
> > generic guess, and should only be used when you haven't yet had the time
> > to come up with a more appropriate function.
>
> Having one for char* but not for string is a bit of a contradiction.
I'd like to remove the one for char*, actually...
The implementation of hashing currently being proposed for C++0x apparently
uses a completely different interface. I'd rather just improve the
(eventual) standard version, rather than kicking along the extensions that
we inherited.
Phil
--
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace. We seek
not your counsel, nor your arms. Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen. - Samuel Adams
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: libstdc++/3552: missing hash function for std::string
@ 2002-05-08 10:06 Goswin Brederlow
0 siblings, 0 replies; 9+ messages in thread
From: Goswin Brederlow @ 2002-05-08 10:06 UTC (permalink / raw)
To: gdr; +Cc: gcc-prs
The following reply was made to PR libstdc++/3552; it has been noted by GNATS.
From: Goswin Brederlow <goswin.brederlow@student.uni-tuebingen.de>
To: Phil Edwards <phil@jaj.com>
Cc: Vadim Ogranovich <vograno@arbitrade.com>,
"'goswin.brederlow@student.uni-tuebingen.de'" <goswin.brederlow@student.uni-tuebingen.de>,
"'gcc-gnats@gcc.gnu.org'" <gcc-gnats@gcc.gnu.org>,
"'Laurent.Bonnaud@inpg.fr'" <Laurent.Bonnaud@inpg.fr>,
"'87063-quiet@bugs.debian.org'" <87063-quiet@bugs.debian.org>,
"'gcc-bugs@gcc.gnu.org'" <gcc-bugs@gcc.gnu.org>
Subject: Re: libstdc++/3552: missing hash function for std::string
Date: 08 May 2002 19:01:45 +0200
Phil Edwards <phil@jaj.com> writes:
> On Sat, Apr 27, 2002 at 02:37:52PM -0500, Vadim Ogranovich wrote:
> > Hi, I independently came across this bug. It seems like it was classified as
> > not a bug with no workaround posted. Is that the case? Thanks, Vadim
Actually the bug was more on the line that the STL _does_ guess for
char* but not for string and that it should use the char* hash
function for strings too.
> Yes. How can we possibly guess what a good hash function would be for
> arbitrary strings? Efficiency of hashing is extremely dependant on the
> data being hashed. You need to write one that's appropriate for your data;
> this will involve multiple experiments.
>
> There is std::collate::hash() for char*'s, but this is essentially a
> generic guess, and should only be used when you haven't yet had the time
> to come up with a more appropriate function.
Having one for char* but not for string is a bit of a contradiction.
MfG
Goswin
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: libstdc++/3552: missing hash function for std::string
@ 2002-04-29 12:56 Vadim Ogranovich
0 siblings, 0 replies; 9+ messages in thread
From: Vadim Ogranovich @ 2002-04-29 12:56 UTC (permalink / raw)
To: gdr; +Cc: gcc-prs
The following reply was made to PR libstdc++/3552; it has been noted by GNATS.
From: Vadim Ogranovich <vograno@arbitrade.com>
To: "'Phil Edwards'" <phil@jaj.com>
Cc: "'goswin.brederlow@student.uni-tuebingen.de'"
<goswin.brederlow@student.uni-tuebingen.de>,
"'gcc-gnats@gcc.gnu.org'"
<gcc-gnats@gcc.gnu.org>,
"'Laurent.Bonnaud@inpg.fr'"
<Laurent.Bonnaud@inpg.fr>,
"'87063-quiet@bugs.debian.org'"
<87063-quiet@bugs.debian.org>,
"'gcc-bugs@gcc.gnu.org'"
<gcc-bugs@gcc.gnu.org>
Subject: RE: libstdc++/3552: missing hash function for std::string
Date: Mon, 29 Apr 2002 14:34:18 -0500
-----Original Message-----
From: Phil Edwards [mailto:phil@jaj.com]
Sent: Monday, April 29, 2002 12:10 PM
To: Vadim Ogranovich
Cc: 'goswin.brederlow@student.uni-tuebingen.de';
'gcc-gnats@gcc.gnu.org'; 'Laurent.Bonnaud@inpg.fr';
'87063-quiet@bugs.debian.org'; 'gcc-bugs@gcc.gnu.org'
Subject: Re: libstdc++/3552: missing hash function for std::string
On Sat, Apr 27, 2002 at 02:37:52PM -0500, Vadim Ogranovich wrote:
>> Hi, I independently came across this bug. It seems like it was classified
as
>> not a bug with no workaround posted. Is that the case? Thanks, Vadim
>Yes. How can we possibly guess what a good hash function would be for
>arbitrary strings? Efficiency of hashing is extremely dependant on the
>data being hashed.
Writing a generic library (STL in this case) necessarily involves making
guesses and choosing solutions that may be sub-optimal in specialized cases.
For most people std::string is a wrapper around char* and if one can make a
default choice for one I see no reason not to do the same choice for the
other.
I have even stronger opinion about the fact that no workaround is posted
along with the bug description.
Thanks, Vadim
--------------------------------------------------
DISCLAIMER
This e-mail, and any attachments thereto, is intended only for use by the
addressee(s) named herein and may contain legally privileged and/or
confidential information. If you are not the intended recipient of this
e-mail, you are hereby notified that any dissemination, distribution or
copying of this e-mail, and any attachments thereto, is strictly prohibited.
If you have received this e-mail in error, please immediately notify me and
permanently delete the original and any copy of any e-mail and any printout
thereof.
E-mail transmission cannot be guaranteed to be secure or error-free. The
sender therefore does not accept liability for any errors or omissions in
the contents of this message which arise as a result of e-mail transmission.
NOTICE REGARDING PRIVACY AND CONFIDENTIALITY
Knight Trading Group may, at its discretion, monitor and review the content
of all e-mail communications.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: libstdc++/3552: missing hash function for std::string
@ 2002-04-29 12:46 Phil Edwards
0 siblings, 0 replies; 9+ messages in thread
From: Phil Edwards @ 2002-04-29 12:46 UTC (permalink / raw)
To: gdr; +Cc: gcc-prs
The following reply was made to PR libstdc++/3552; it has been noted by GNATS.
From: Phil Edwards <phil@jaj.com>
To: Vadim Ogranovich <vograno@arbitrade.com>
Cc: "'goswin.brederlow@student.uni-tuebingen.de'" <goswin.brederlow@student.uni-tuebingen.de>,
"'gcc-gnats@gcc.gnu.org'" <gcc-gnats@gcc.gnu.org>,
"'Laurent.Bonnaud@inpg.fr'" <Laurent.Bonnaud@inpg.fr>,
"'87063-quiet@bugs.debian.org'" <87063-quiet@bugs.debian.org>,
"'gcc-bugs@gcc.gnu.org'" <gcc-bugs@gcc.gnu.org>
Subject: Re: libstdc++/3552: missing hash function for std::string
Date: Mon, 29 Apr 2002 15:44:47 -0400
On Mon, Apr 29, 2002 at 02:34:18PM -0500, Vadim Ogranovich wrote:
> I have even stronger opinion about the fact that no workaround is posted
> along with the bug description.
The "workaround" is to treat string as you would treat any of your
own classes which you want to store in a hashed container: write a
specialization for it.
The hashing components came from SGI. Here is their documentation:
http://www.sgi.com/tech/stl/HashFunction.html
Read the notes at the end, and follow the "hash model" link for more
examples.
--
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace. We seek
not your counsel, nor your arms. Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen. - Samuel Adams
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: libstdc++/3552: missing hash function for std::string
@ 2002-04-29 12:16 Phil Edwards
0 siblings, 0 replies; 9+ messages in thread
From: Phil Edwards @ 2002-04-29 12:16 UTC (permalink / raw)
To: gdr; +Cc: gcc-prs
The following reply was made to PR libstdc++/3552; it has been noted by GNATS.
From: Phil Edwards <phil@jaj.com>
To: Vadim Ogranovich <vograno@arbitrade.com>
Cc: "'goswin.brederlow@student.uni-tuebingen.de'" <goswin.brederlow@student.uni-tuebingen.de>,
"'gcc-gnats@gcc.gnu.org'" <gcc-gnats@gcc.gnu.org>,
"'Laurent.Bonnaud@inpg.fr'" <Laurent.Bonnaud@inpg.fr>,
"'87063-quiet@bugs.debian.org'" <87063-quiet@bugs.debian.org>,
"'gcc-bugs@gcc.gnu.org'" <gcc-bugs@gcc.gnu.org>
Subject: Re: libstdc++/3552: missing hash function for std::string
Date: Mon, 29 Apr 2002 15:09:32 -0400
On Sat, Apr 27, 2002 at 02:37:52PM -0500, Vadim Ogranovich wrote:
> Hi, I independently came across this bug. It seems like it was classified as
> not a bug with no workaround posted. Is that the case? Thanks, Vadim
Yes. How can we possibly guess what a good hash function would be for
arbitrary strings? Efficiency of hashing is extremely dependant on the
data being hashed. You need to write one that's appropriate for your data;
this will involve multiple experiments.
There is std::collate::hash() for char*'s, but this is essentially a
generic guess, and should only be used when you haven't yet had the time
to come up with a more appropriate function.
--
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace. We seek
not your counsel, nor your arms. Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen. - Samuel Adams
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: libstdc++/3552: missing hash function for std::string
@ 2002-04-27 12:46 Vadim Ogranovich
0 siblings, 0 replies; 9+ messages in thread
From: Vadim Ogranovich @ 2002-04-27 12:46 UTC (permalink / raw)
To: gdr; +Cc: gcc-prs
The following reply was made to PR libstdc++/3552; it has been noted by GNATS.
From: Vadim Ogranovich <vograno@arbitrade.com>
To: "'goswin.brederlow@student.uni-tuebingen.de'"
<goswin.brederlow@student.uni-tuebingen.de>,
"'gcc-gnats@gcc.gnu.org'"
<gcc-gnats@gcc.gnu.org>,
"'gcc-prs@gcc.gnu.org'" <gcc-prs@gcc.gnu.org>,
"'Laurent.Bonnaud@inpg.fr'" <Laurent.Bonnaud@inpg.fr>,
"'87063-quiet@bugs.debian.org'" <87063-quiet@bugs.debian.org>,
"'gcc-bugs@gcc.gnu.org'" <gcc-bugs@gcc.gnu.org>
Cc:
Subject: Re: libstdc++/3552: missing hash function for std::string
Date: Sat, 27 Apr 2002 14:37:52 -0500
Hi, I independently came across this bug. It seems like it was classified as
not a bug with no workaround posted. Is that the case? Thanks, Vadim
P.S. From searching the Web I found that this "not-a-bug" first surfaced in
1998 and has been bugging people since then.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view audit-trail
--------------------------------------------------
DISCLAIMER
This e-mail, and any attachments thereto, is intended only for use by the
addressee(s) named herein and may contain legally privileged and/or
confidential information. If you are not the intended recipient of this
e-mail, you are hereby notified that any dissemination, distribution or
copying of this e-mail, and any attachments thereto, is strictly prohibited.
If you have received this e-mail in error, please immediately notify me and
permanently delete the original and any copy of any e-mail and any printout
thereof.
E-mail transmission cannot be guaranteed to be secure or error-free. The
sender therefore does not accept liability for any errors or omissions in
the contents of this message which arise as a result of e-mail transmission.
NOTICE REGARDING PRIVACY AND CONFIDENTIALITY
Knight Trading Group may, at its discretion, monitor and review the content
of all e-mail communications.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: libstdc++/3552: missing hash function for std::string
@ 2001-07-03 16:26 Gabriel Dos Reis
0 siblings, 0 replies; 9+ messages in thread
From: Gabriel Dos Reis @ 2001-07-03 16:26 UTC (permalink / raw)
To: gdr; +Cc: gcc-prs
The following reply was made to PR libstdc++/3552; it has been noted by GNATS.
From: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
To: 87063-quiet@bugs.debian.org
Cc: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org,
Matthias Klose <doko@klose.in-berlin.de>
Subject: Re: libstdc++/3552: missing hash function for std::string
Date: 04 Jul 2001 01:15:24 +0200
Matthias Klose <doko@klose.in-berlin.de> writes:
[...]
| This one is clearly a bug.
In which sense?
There is no standard class named hash_map<>.
-- Gaby
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: libstdc++/3552: missing hash function for std::string
@ 2001-07-03 16:18 gdr
0 siblings, 0 replies; 9+ messages in thread
From: gdr @ 2001-07-03 16:18 UTC (permalink / raw)
To: Laurent.Bonnaud, 87063-quiet, gcc-bugs, gcc-prs, gdr,
goswin.brederlow, nobody
Synopsis: missing hash function for std::string
Responsible-Changed-From-To: unassigned->gdr
Responsible-Changed-By: gdr
Responsible-Changed-When: Tue Jul 3 16:18:48 2001
Responsible-Changed-Why:
Analyzed.
State-Changed-From-To: open->closed
State-Changed-By: gdr
State-Changed-When: Tue Jul 3 16:18:48 2001
State-Changed-Why:
Request for extension.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3552&database=gcc
^ permalink raw reply [flat|nested] 9+ messages in thread
* libstdc++/3552: missing hash function for std::string
@ 2001-07-03 15:26 Matthias Klose
0 siblings, 0 replies; 9+ messages in thread
From: Matthias Klose @ 2001-07-03 15:26 UTC (permalink / raw)
To: gcc-gnats, debian-gcc
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2037 bytes --]
>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:
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2002-05-08 18:46 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-08 11:46 libstdc++/3552: missing hash function for std::string Phil Edwards
-- strict thread matches above, loose matches on Subject: below --
2002-05-08 10:06 Goswin Brederlow
2002-04-29 12:56 Vadim Ogranovich
2002-04-29 12:46 Phil Edwards
2002-04-29 12:16 Phil Edwards
2002-04-27 12:46 Vadim Ogranovich
2001-07-03 16:26 Gabriel Dos Reis
2001-07-03 16:18 gdr
2001-07-03 15:26 Matthias Klose
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).