Boost C++ Libraries: Ticket #13265: boost atomic lib memory_order error https://svn.boost.org/trac10/ticket/13265 <p> boost atomic lib memory_order error. </p> <p> someone deleted memory_order_release/memory_order_acquire code, which should be translate to sfence/lfence , but now you see that they were removed. </p> <p> BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT { </p> <blockquote> <p> if (order == memory_order_seq_cst) { </p> <blockquote> <p> <span class="underline">asm</span> <span class="underline">volatile</span> ( </p> </blockquote> </blockquote> <table class="wiki"> <tr>#if defined(<span class="underline">x86_64</span>) <td> defined(<span class="underline">SSE2</span>) </td></tr></table> <blockquote> <p> "mfence\n" </p> </blockquote> <p> #else </p> <blockquote> <p> "lock; addl $0, (%%esp)\n" </p> </blockquote> <p> #endif </p> <blockquote> <p> ::: "memory" </p> </blockquote> <blockquote> <p> ); </p> </blockquote> <blockquote> <p> } else if ((order &amp; (memory_order_acquire | memory_order_release)) != 0) { </p> <blockquote> <p> <span class="underline">asm</span> <span class="underline">volatile</span> ("" ::: "memory"); </p> </blockquote> <p> } </p> </blockquote> <p> } </p> <p> I suggest code is: </p> <p> BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT { </p> <blockquote> <p> if (order == memory_order_seq_cst) { </p> <blockquote> <p> <span class="underline">asm</span> <span class="underline">volatile</span> ( </p> </blockquote> </blockquote> <table class="wiki"> <tr>#if defined(<span class="underline">x86_64</span>) <td> defined(<span class="underline">SSE2</span>) </td></tr></table> <blockquote> <p> "mfence\n" </p> </blockquote> <p> #else </p> <blockquote> <p> "lock; addl $0, (%%esp)\n" </p> </blockquote> <p> #endif </p> <blockquote> <p> ::: "memory" </p> </blockquote> <blockquote> <p> ); </p> </blockquote> <blockquote> <p> return; } </p> </blockquote> <blockquote> <p> if ((order &amp; (memory_order_acquire )!=0 ){ </p> <blockquote> <p> <span class="underline">asm</span> <span class="underline">volatile</span> ( </p> </blockquote> </blockquote> <table class="wiki"> <tr>#if defined(<span class="underline">x86_64</span>) <td> defined(<span class="underline">SSE2</span>) </td></tr></table> <blockquote> <p> "lfence\n" </p> </blockquote> <p> #else </p> <blockquote> <p> "lock; addl $0, (%%esp)\n" </p> </blockquote> <p> #endif </p> <blockquote> <p> ::: "memory" </p> </blockquote> <blockquote> <p> ); </p> </blockquote> <blockquote> <p> return; } </p> </blockquote> <blockquote> <p> if ((order &amp; (memory_order_release )!=0 ){ </p> <blockquote> <p> <span class="underline">asm</span> <span class="underline">volatile</span> ( </p> </blockquote> </blockquote> <table class="wiki"> <tr>#if defined(<span class="underline">x86_64</span>) <td> defined(<span class="underline">SSE2</span>) </td></tr></table> <blockquote> <p> "sfence\n" </p> </blockquote> <p> #else </p> <blockquote> <p> "lock; addl $0, (%%esp)\n" </p> </blockquote> <p> #endif </p> <blockquote> <p> ::: "memory" </p> </blockquote> <blockquote> <p> ); </p> </blockquote> <blockquote> <p> } </p> </blockquote> <p> } </p> <p> Linux system do not delete lfence and sfence code, but why C++ lib deleted, this will cause error in multi_thread programe. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13265 Trac 1.4.3