Boost C++ Libraries: Ticket #2825: class boost::detail::atomic_count assumes long == int https://svn.boost.org/trac10/ticket/2825 <p> boost::detail::atomic_count (as defined in atomic_count_gcc_x86.hpp, at least), has a member variable value_ that is of type int, yet the class constructor and operators use type long. When building for 64 bit targets on MacOS 10.5 and other LP64 architectures, long is 64 bits, while int is 32, leading to silent truncation if a 64 bit value were used to construct an atomic_count. Changing all of the signatures to use int instead of long solves this problem. It would probably be even safer to replace all the ints with boost::int32_t, assuming that the atomic operations being used really require 32 bit integers. </p> <pre class="wiki"> explicit atomic_count( int v ) : value_( v ) {} void operator++() { __asm__ ( "lock\n\t" "incl %0": "+m"( value_ ): // output (%0) : // inputs "cc" // clobbers ); } int operator--() { return atomic_exchange_and_add( &amp;value_, -1 ) - 1; } operator int() const { return atomic_exchange_and_add( &amp;value_, 0 ); } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2825 Trac 1.4.3 Peter Dimov Tue, 01 Dec 2009 01:47:52 GMT milestone changed https://svn.boost.org/trac10/ticket/2825#comment:1 https://svn.boost.org/trac10/ticket/2825#comment:1 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.39.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket Peter Dimov Thu, 24 Feb 2011 17:23:30 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2825#comment:2 https://svn.boost.org/trac10/ticket/2825#comment:2 <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">wontfix</span> </li> </ul> Ticket