Boost C++ Libraries: Ticket #13121: std_fenced_block gets used for g++ 4.6.4 and hence buggy std::atomic_thread_fence https://svn.boost.org/trac10/ticket/13121 <p> With g++ 4.6.4: using <code>asio</code> code that results in <code>detail::fenced_block</code> being used results in <code>detail::std_fenced_block</code> being used. This uses <code>std::atomic_thread_fence</code> but that has link issues with 4.6 (maybe <a class="ext-link" href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51038"><span class="icon">​</span>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51038</a>). </p> <p> <code>g++4.6 -std=c++0x -I boost... </code> </p> <pre class="wiki">#include &lt;boost/asio/detail/fenced_block.hpp&gt; #ifdef BOOST_ASIO_HAS_STD_ATOMIC # pragma message("Will use asio std_fenced_block") #endif int main(int argc, char *argv[]) { (void)argc; (void)argv; boost::asio::detail::fenced_block block(boost::asio::detail::fenced_block::full); } </pre><p> boost_asio.cpp:4:51: note: #pragma message: Will use asio std_fenced_block /tmp/ccNS0287.o: In function `boost::asio::detail::std_fenced_block::std_fenced_block(boost::asio::detail::std_fenced_block::full_t)': boost_asio.cpp:(.text._ZN5boost4asio6detail16std_fenced_blockC2ENS2_6full_tE[_ZN5boost4asio6detail16std_fenced_blockC5ENS2_6full_tE]+0x22): undefined reference to `std::atomic_thread_fence(std::memory_order)' /tmp/ccNS0287.o: In function `boost::asio::detail::std_fenced_block::~std_fenced_block()': boost_asio.cpp:(.text._ZN5boost4asio6detail16std_fenced_blockD2Ev[_ZN5boost4asio6detail16std_fenced_blockD5Ev]+0x13): undefined reference to `std::atomic_thread_fence(std::memory_order)' collect2: ld returned 1 exit status </p> <p> It looks like between 1.63 and 1.64, in <em>detail/fenced_block.hpp</em>, the <code>#elif defined(BOOST_ASIO_HAS_STD_ATOMIC)</code> line takes precedence over the specific gcc test. However, <code>BOOST_ASIO_HAS_STD_ATOMIC</code> is defined for 4.6.4. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13121 Trac 1.4.3 Richard Hazlewood <boost@…> Thu, 13 Jul 2017 11:40:15 GMT attachment set https://svn.boost.org/trac10/ticket/13121 https://svn.boost.org/trac10/ticket/13121 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_1_64_0-asio.patch</span> </li> </ul> <p> One example patch </p> Ticket mikealeonetti@… Wed, 09 Aug 2017 20:47:58 GMT <link>https://svn.boost.org/trac10/ticket/13121#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13121#comment:1</guid> <description> <p> The patch worked for me. Using gcc version 4.6.3 (Debian 4.6.3-14+rpi1) on Raspian. Fixed the compile issue. </p> </description> <category>Ticket</category> </item> </channel> </rss>