public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: vograno@arbitrade.com
To: gcc-gnats@gcc.gnu.org
Subject: libstdc++/6791: hash_map: bad end() iterator
Date: Thu, 23 May 2002 20:26:00 -0000	[thread overview]
Message-ID: <20020524031825.2901.qmail@sources.redhat.com> (raw)


>Number:         6791
>Category:       libstdc++
>Synopsis:       hash_map: bad end() iterator
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 23 20:26:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Vadim Ogranovich
>Release:        gcc version 3.0.4
>Organization:
>Environment:
Linux
>Description:
The following program produces a segmentation fault. It works fine if map is used instead of hash_map.
Note also that a number of calls to the destructor ~Foo() exceeds the number of constructor calls (not a bug per se, but looks strage).

//file foo.cpp
#include <iostream>
#include <map>
#include <ext/hash_map>

using namespace std;


class Foo {
public:
  Foo() {
    cerr << "constructed\n";
  }

  ~Foo() {
    cerr << "destructed\n";
  }
};

typedef  hash_map<int, Foo> HT;

int main()
{
  HT fooH;
  fooH[0] = Foo();

  for (HT::iterator iter=fooH.begin(); iter!=fooH.end(); ++iter) {
    cerr << "erasing\n";
    fooH.erase(iter);
  }

  return 0;
}
>How-To-Repeat:
save to foo.cpp
compile: g++ -g   foo.cpp -o foo
run: ./foo
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-05-24  3:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-23 20:26 vograno [this message]
2002-05-24 10:46 paolo
2002-05-24 11:36 Vadim Ogranovich

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=20020524031825.2901.qmail@sources.redhat.com \
    --to=vograno@arbitrade.com \
    --cc=gcc-gnats@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).