Opened 7 years ago

Closed 7 years ago

#11628 closed Bugs (fixed)

small_vector<int,n> iterates over elements in destructor

Reported by: benjamin.redelings@… Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: container
Version: Boost 1.59.0 Severity: Problem
Keywords: Cc:

Description

In the destruction of a small_vector<int,10>, gdb reveals that the integers are individually destroyed, which makes destruction linear in the size of the object.

The code that does this linear-time destruction is the code below from container/detail/copy_move_algo.hpp:

template

<typename Allocator,

typename I, I models InputIterator

,typename U> U models unsigned integral constant

inline typename container_detail::disable_if_trivially_destructible<I, void>::type destroy_alloc_n(Allocator &a, I f, U n) { while(n--){

allocator_traits<Allocator>::destroy(a,container_detail::iterator_to_raw_pointer(f)); ++f;

}

Since int is a POD type, it seems that this loop shouldn't be executed. It appears that the type variable I takes on the value "int*".

Attachments (1)

test2.C (429 bytes ) - added by benjamin.redelings@… 7 years ago.
test case

Download all attachments as: .zip

Change History (2)

by benjamin.redelings@…, 7 years ago

Attachment: test2.C added

test case

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

Resolution: fixed
Status: newclosed

Thanks for the report. It seems that the trait that avoids the linear iteration was commented in a test and committed inadvertently. Fixed in:

https://github.com/boostorg/container/commit/f1f97518d338c7f7351308aa1785ebae5f2ddde7

Note: See TracTickets for help on using tickets.