Boost C++ Libraries: Ticket #11148: attribute_value_set.size() is busted https://svn.boost.org/trac10/ticket/11148 <p> The problem can be illustrated with some code like this: </p> <pre class="wiki"> using boost::log::attribute_value_set; const attribute_value_set&amp; values(record.attribute_values()); const boost::log::attribute_value_set::size_type count( values.size()); for (attribute_value_set::value_type i : values) { ... } </pre><p> Under some circumstances we see that the for loop iterates over more than 'count' attribute values. </p> <p> The problem is in attribute_value_set::implementation::size(), which looks like this: </p> <pre class="wiki">size_type size() { freeze(); return (m_pEnd - m_pStorage); } </pre><p> This works correctly when the set does not contain more attributes than fit in the pre-allocated block pointed to by m_pStorage. But, looking at attribute_value_set::implementation::insert_node(), we see that once the internal node storage is exhausted, additional nodes are allocated on-the-fly and are not accounted for in the computation in size(): </p> <pre class="wiki">node* insert_node(key_type key, bucket&amp; b, node* where, mapped_type data) { node* p; if (m_pEnd != m_pEOS) { p = m_pEnd++; new (p) node(key, data, false); } else { p = new node(key, data, true); } ... </pre><p> I have not looked, but this problem may also exist in other attribute_value_set like containers. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11148 Trac 1.4.3 Andrey Semashev Sat, 28 Mar 2015 16:08:37 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11148#comment:1 https://svn.boost.org/trac10/ticket/11148#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed in <a class="ext-link" href="https://github.com/boostorg/log/commit/f74a7df2df0947da7927782424924d605f11c349"><span class="icon">​</span>https://github.com/boostorg/log/commit/f74a7df2df0947da7927782424924d605f11c349</a>. Thanks for reporting this. </p> Ticket