[intrusive] crash with slist push_back
Hi Boost Dev,
Please consider the following code, this crashes with slist but works just
fine if I replace slist with list. Also flat_map crashes but std::map works
fine. Am I doing something gross or is there a bug here?
#include <iostream>
#include
On 10/05/2016 15:14, Arpan Sen wrote:
#include <iostream> #include
#include <map> //#include #include using namespace boost::intrusive;
struct m : public slist_base_hook<> { int n; public: m(int k) : n(k) { } };
int main() { boost::container::flat_map
> c1; std::map > c2; m* m1 = new m(22); c1[1].push_back(*m1); m* tt = new m(99); c2[1].push_back(*tt); }
It's a bug in the implementation of the slist's move constructor, it fails to initialize the internal last element cache. Please try to change this: slist_impl(BOOST_RV_REF(slist_impl) x) : data_(::boost::move(x.priv_value_traits())) { this->priv_size_traits().set_size(size_type(0)); node_algorithms::init_header(this->get_root_node()); //nothrow, no need to rollback to release elements on exception this->swap(x); } with this: slist_impl(BOOST_RV_REF(slist_impl) x) : data_(::boost::move(x.priv_value_traits())) { this->set_default_constructed_state(); //nothrow, no need to rollback to release elements on exception this->swap(x); } Best, Ion
participants (2)
-
Arpan Sen
-
Ion GaztaƱaga