Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions include/boost/circular_buffer/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,8 @@ private empty_value<Alloc>
if (full()) {
if (empty())
return;
replace(m_last, value_type(::boost::forward<Args>(args)...));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is wrong. This is your bug!

This is where the temporary object gets created.

What do you think value_type(...) is doing?

It creates a temporary object and call the replace() method that is using assignment!

destroy_item(m_last);
boost::allocator_construct(alloc(), boost::to_address(m_last), ::boost::forward<Args>(args)...);
increment(m_last);
m_first = m_last;
} else {
Expand All @@ -1475,7 +1476,8 @@ private empty_value<Alloc>
if (full()) {
if (empty())
return;
replace(m_last, value_type(::boost::forward<V>(value)));
destroy_item(m_last);
boost::allocator_construct(alloc(), boost::to_address(m_last), ::boost::forward<Args>(args)...);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has not been compiled with BOOST_NO_CXX11_VARIADIC_TEMPLATES defined because I do not think this would compile.

There is no variadic template parameter Args (args) here

increment(m_last);
m_first = m_last;
} else {
Expand All @@ -1494,7 +1496,8 @@ private empty_value<Alloc>
if (empty())
return;
decrement(m_first);
replace(m_first, value_type(::boost::forward<Args>(args)...));
destroy_item(m_first);
boost::allocator_construct(alloc(), boost::to_address(m_first), ::boost::forward<Args>(args)...);
m_last = m_first;
} else {
decrement(m_first);
Expand All @@ -1515,7 +1518,8 @@ private empty_value<Alloc>
if (empty())
return;
decrement(m_first);
replace(m_first, value_type(::boost::forward<V>(value)));
destroy_item(m_first);
boost::allocator_construct(alloc(), boost::to_address(m_first), ::boost::forward<Args>(args)...);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has not been compiled with BOOST_NO_CXX11_VARIADIC_TEMPLATES defined because I do not think this would compile.

There is no variadic template parameter Args (args) here

m_last = m_first;
} else {
decrement(m_first);
Expand Down