From 203764eb51ba0bfb0ac3ea96d23c9e9dc566bc12 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 19 Apr 2006 21:03:18 +0000 Subject: [PATCH] Fix VC6 codegen issue (Alain Cormier) [SVN r33747] --- include/boost/detail/sp_counted_base_w32.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/boost/detail/sp_counted_base_w32.hpp b/include/boost/detail/sp_counted_base_w32.hpp index e84f06e..fb42c4e 100644 --- a/include/boost/detail/sp_counted_base_w32.hpp +++ b/include/boost/detail/sp_counted_base_w32.hpp @@ -25,6 +25,7 @@ // #include +#include #include namespace boost @@ -78,7 +79,19 @@ public: { long tmp = static_cast< long const volatile& >( use_count_ ); if( tmp == 0 ) return false; + +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1200 ) + + // work around a code generation bug + + long tmp2 = tmp + 1; + if( BOOST_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp2, tmp ) == tmp2 - 1 ) return true; + +#else + if( BOOST_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp + 1, tmp ) == tmp ) return true; + +#endif } }