This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Bug ? in hash_map template
- From: Patrick Percot <ppercot at free dot fr>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 24 Aug 2004 20:27:19 +0200 (CEST)
- Subject: Bug ? in hash_map template
Hi,
I made some tests with g++ 3.2.3 and g++ 3.3.1 on GNU/Linux and on
cygwin g++ 3.3.1. And I got the same results : when I run this program,
when inserting "key20" to "key24" the size of the hash_map does not
evolve.
When I try to get the results back, "key15" to "key19" all give the
result 20.
I noticed something when debugging the code, in the function resize, the
current size is compared to _M_bucket.size() that allways returns 193.
Does someone noticed the same behavior ?
#include <ext/hash_map>
#include <iostream>
using namespace std;
using namespace __gnu_cxx;
struct eqstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) == 0;
}
};
int
main()
{
char str[128];
hash_map<const char*, int, hash<const char*>, eqstr> h;
cout << "hash size = " << h.size() << '\n';
for (int i = 0; i < 31; ++i) {
sprintf(str, "key%d", i);
h[str] = i;
cout << "size = " << h.size() << " str = " << str << '\n';
}
for (int i = 0; i < 31; ++i) {
sprintf(str, "key%d", i);
cout << str << " = " << h[str] << '\n';
}
}
À+
PP
--
Groupe Morbihannais d'Utilisateurs de Logiciels Libres http://www.tuxbihan.org
Identifiant Jabber: pp@amessage.de
GPG fingerprint = 1A4F E154 3D2C A20E E4CA A543 7951 C5C2 E44A A0B5
Patrick Percot.