Re: [Boost-bugs] [Boost C++ Libraries] #11830: small_vector move is broken

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11830: small_vector move is broken
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-12-06 08:05:25

#11830: small_vector move is broken
  Reporter: mrmiller <michael_miller@…> | Owner: igaztanaga
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: container
   Version: Boost 1.59.0 | Severity: Showstopper
Resolution: | Keywords: small_vector move

Comment (by mrmiller <michael_miller@…>):

 I located a couple different problem spots that seem to fix the issue in
 the cases I've tested. On my end, I refactored steal_resources and broke
 out the resetting into clear_resources:

    void steal_resources(vector_alloc_holder &x) BOOST_NOEXCEPT_OR_NOTHROW
       this->m_start = x.m_start;
       this->m_size = x.m_size;
       this->m_capacity = x.m_capacity;

    void clear_resources() BOOST_NOEXCEPT_OR_NOTHROW
       this->m_start = pointer();
       this->m_size = this->m_capacity = 0;

 Every time we use a move_iterator to do the copy because the allocator
 isn't propagable, we need to clear out the previous allocator. That means
 simply adding x.clear_resources() after the call to assign in
 vector::priv_move_assign and small_vector::move_construct_impl.

 Lastly, small_vector's move constructor seems rather suspect to me:
    small_vector(BOOST_RV_REF(small_vector) other)
       : base_type(initial_capacity_t(), internal_capacity(),
    { this->move_construct_impl(other, other.get_stored_allocator()); }

 That call to other.get_stored_allocator() looks really suspicious after
 we've moved the allocator in the initializer...

Ticket URL: <>
Boost C++ Libraries <>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC