Opened 9 years ago

Closed 7 years ago

#9931 closed Bugs (fixed)

flat_map::insert(ordered_unique_range_t...) fails with move_iterators

Reported by: boost@… Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: container
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

This code asserts:

flat_map<int, std::string> m1; m1.emplace(1, "one"); m1.emplace(5, "five"); m1.emplace(3, "three");

flat_map<int, std::string> m2; m2.emplace(6, "six"); m2.emplace(7, "seven"); m2.emplace(8, "eight");

m1.insert(

boost::container::ordered_unique_range_t(), std::make_move_iterator(std::begin(m2)), std::make_move_iterator(std::end(m2)));

assert(m1[6] == "six"); <- fails, m1[6] is empty

insert() accesses the iterator multiple times, trying to determine if it can insert a range of values in a burst.

Change History (6)

comment:1 by Ion Gaztañaga, 9 years ago

Resolution: fixed
Status: newclosed

Thanks for the report. I've reproduced it and found that due to the internal representation of flat_map using a custom pair, a conversion was triggered when dereferencing the iterator when inserting. Fixed in:

[develop 5013f3f] Fixes #9931 ("flat_map::insert(ordered_unique_range_t...) fails with move_iterators")

comment:2 by anonymous, 8 years ago

It doesn't seem to be fixed in boost 1.57.0, the example code still asserts for me.

comment:3 by anonymous, 8 years ago

Resolution: fixed
Status: closedreopened

comment:5 by viboes, 7 years ago

What about closing this or moving it to support?

comment:6 by Ion Gaztañaga, 7 years ago

Resolution: fixed
Status: reopenedclosed

Closing as fixed as there is no error report since the last fix.

Note: See TracTickets for help on using tickets.