Boost C++ Libraries: Ticket #109: counted_base::add_ref not overflow-safe https://svn.boost.org/trac10/ticket/109 <pre class="wiki">Greetings, In order to track the number of shared_ptrs that refer to a certain object, the function counted_base::add_ref calls the overloaded operator ++() of the corresponding count_type member data. That in turn does increment a variable of built-in type (volatile long), but it does not check wether the result fits into the variable or not. A possible solution: a) in atomic_count::operator ++(): if(value_ != std::numeric_limits&lt;volatile long&gt;::max()) ...call atomic increment else throw ... some exception b) at least mention this somewhere in the documentation. Although this is certainly a situation unlikely to be ever appearing in practice, it might happen and can be the source for lots of trouble. best regards, Thomas Mang </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/109 Trac 1.4.3 shammah Tue, 27 Aug 2002 01:47:20 GMT <link>https://svn.boost.org/trac10/ticket/109#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/109#comment:1</guid> <description> <pre class="wiki">Logged In: YES user_id=146506 "unlikely" is right; this would require std::numeric_limits&lt;long&gt;::max() smart pointer objects. I do not think that this constitutes a change to the code. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Wed, 28 May 2003 12:40:45 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/109#comment:2 https://svn.boost.org/trac10/ticket/109#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> Ticket