public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Patrick Percot <ppercot@free.fr>
To: gcc-help@gcc.gnu.org
Subject: Bug ? in hash_map template
Date: Wed, 25 Aug 2004 20:45:00 -0000	[thread overview]
Message-ID: <20040824.202719.35012417.ppercot@free.fr> (raw)

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.

                 reply	other threads:[~2004-08-24 18:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040824.202719.35012417.ppercot@free.fr \
    --to=ppercot@free.fr \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).