Opened 3 years ago

Closed 3 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:


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:


<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@… 3 years ago.
test case

Download all attachments as: .zip

Change History (2)

Changed 3 years ago by benjamin.redelings@…

Attachment: test2.C added

test case

comment:1 Changed 3 years ago by Ion Gaztañaga

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:

Note: See TracTickets for help on using tickets.