public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/61667] New: setting max_load_factor of unordered_map cause buckets shrink
@ 2014-07-02  9:10 tinrow at gmail dot com
  2014-07-02  9:43 ` [Bug libstdc++/61667] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: tinrow at gmail dot com @ 2014-07-02  9:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61667

            Bug ID: 61667
           Summary: setting max_load_factor of unordered_map cause buckets
                    shrink
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tinrow at gmail dot com

I want to build an unordered_map with at least 200000 initial buckets and set
max load factor to 0.5. The bucket count shrinks to 2 during call to
max_load_factor.

Reproduce:
$ cat 1.cpp 
#include <unordered_map>
#include <iostream>

using namespace std;

int main () {
  unordered_map<int, int> m(200000);
  cout << m.bucket_count() << endl;
  m.max_load_factor(0.5);
  cout << m.bucket_count() << endl;
  return 0;
}

$ g++ -std=c++11 1.cpp 
$ ./a.out 
202409
2

$ g++ --version
g++ (GCC) 4.8.2

In the ISO/IEC 14882:2011 standard, here is a possible "increase" but no
"shrink".

b.max_load_factor() float
Returns a positive number that the container attempts to keep the load factor
less than or equal to. The container automatically increases the number of
buckets as necessary to keep the load factor below this number.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-08-10  0:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-02  9:10 [Bug libstdc++/61667] New: setting max_load_factor of unordered_map cause buckets shrink tinrow at gmail dot com
2014-07-02  9:43 ` [Bug libstdc++/61667] " redi at gcc dot gnu.org
2014-07-23 20:07 ` fdumont at gcc dot gnu.org
2014-08-09  8:01 ` fdumont at gcc dot gnu.org
2014-08-09 10:19 ` fdumont at gcc dot gnu.org
2014-08-10  0:45 ` redi at gcc dot gnu.org

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).