public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/52476] [C++11] Unordered multimap reorders equivalent elements
Date: Sun, 04 Mar 2012 16:11:00 -0000	[thread overview]
Message-ID: <bug-52476-4-9S92aAUlql@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-52476-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52476

--- Comment #2 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-03-04 16:10:19 UTC ---
(In reply to comment #1)
> (we should double check that by avoiding any use of
> fancy C++11 features like initializer lists in the testcase)

I rewrote the testcase in C++03 form and based on TR1 unordered map:

//------
#include <tr1/unordered_map>
#include <iostream>
#include <utility>

typedef std::tr1::unordered_multimap<int, int> map_type;

void printHashTable(const map_type& map)
{
  for (unsigned i = 0; i < map.bucket_count(); ++i) {
    std::cout << "b[" << i << "]:" << std::endl;
    for (map_type::const_local_iterator it = map.begin(i); it != map.end(i);
++it) {
      std::cout << "   " << map.hash_function()(it->first) << " ["
                << it->first << "," << it->second << "]" << std::endl;
    }
  }
  std::cout << "----------------------" << std::endl;
}

int main()
{
  typedef std::pair<int, int> P;
  const P input1[] = {
    P(0,0),
    P(1,0),
    P(2,0),
    P(3,0),
    P(4,0),
    P(1,1)
  };
  map_type dict(input1, input1 + sizeof(input1)/sizeof(input1[0]));
  printHashTable(dict);

  const P input2[] = {
    P(3,1),
    P(3,2),
    P(5,0)
  };
  dict.insert(input2, input2 + sizeof(input2)/sizeof(input2[0]));
  printHashTable(dict);

  dict.max_load_factor(0.5);
  printHashTable(dict);
}
//------

The incorrect runtime behaviour is unchanged compared to the original form.
This means, one could actually remove the [C++11] tag from the bug title.


  parent reply	other threads:[~2012-03-04 16:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-04 10:57 [Bug libstdc++/52476] New: " daniel.kruegler at googlemail dot com
2012-03-04 11:28 ` [Bug libstdc++/52476] " paolo.carlini at oracle dot com
2012-03-04 16:11 ` daniel.kruegler at googlemail dot com [this message]
2012-03-04 16:28 ` daniel.kruegler at googlemail dot com
2012-03-05  1:09 ` [Bug libstdc++/52476] [DR 518] " paolo.carlini at oracle dot com
2012-03-16 21:42 ` fdumont at gcc dot gnu.org
2012-04-09 19:12 ` fdumont at gcc dot gnu.org
2012-04-09 20:57 ` redi at gcc dot gnu.org
2012-04-10 16:55 ` paolo.carlini at oracle dot com

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=bug-52476-4-9S92aAUlql@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).