Opened 9 years ago
#9523 new Bugs
reserve() corrupts data in boost::bimap vector_of_relation
Reported by: | Owned by: | Matias Capeletto | |
---|---|---|---|
Milestone: | Boost 1.56.0 | Component: | bimap |
Version: | Boost 1.54.0 | Severity: | Problem |
Keywords: | bimap, reserve, vector_of_relation | Cc: |
Description
bimap::reserve() has bad behavior:
- Corrupts the data by inserting item into the empty bimap
- Reserves incorrect amount of elements capacity
Environment: Linux Ubuntu x64 3.2.0-57-generic 87-Ubuntu SMP, gcc (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1
Code:
typedef unsigned Id; const unsigned m_nodes = 1518; typedef boost::bimap<boost::bimaps::unordered_set_of<Id>, boost::bimaps::unconstrained_set_of<Id>, boost::bimaps::vector_of_relation> Nbimap; Nbimap m_nbimap; fprintf(stderr, "Initial bmsize: %u, capacity: %u\n", m_nbimap.size(), m_nbimap.capacity()); m_nbimap.reserve(m_nodes); fprintf(stderr, "Postreserve bmsize: %u, capacity: %u, nsize: %u\n", m_nbimap.size(), m_nbimap.capacity(), m_nodes);
Console output:
Initial bmsize: 0, capacity: 0 Postreserve bmsize: 1, capacity: 15, nsize: 1518
Note:
See TracTickets
for help on using tickets.