Modify

Opened 4 months ago

Last modified 4 months ago

#13121 new Bugs

std_fenced_block gets used for g++ 4.6.4 and hence buggy std::atomic_thread_fence

Reported by: Richard Hazlewood <boost@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.64.0 Severity: Problem
Keywords: g++ 4.6 Cc:

Description

With g++ 4.6.4: using asio code that results in detail::fenced_block being used results in detail::std_fenced_block being used. This uses std::atomic_thread_fence but that has link issues with 4.6 (maybe https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51038).

g++4.6 -std=c++0x -I boost...

#include <boost/asio/detail/fenced_block.hpp>

#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);
}

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

It looks like between 1.63 and 1.64, in detail/fenced_block.hpp, the #elif defined(BOOST_ASIO_HAS_STD_ATOMIC) line takes precedence over the specific gcc test. However, BOOST_ASIO_HAS_STD_ATOMIC is defined for 4.6.4.

Attachments (1)

boost_1_64_0-asio.patch (1.0 KB) - added by Richard Hazlewood <boost@…> 4 months ago.
One example patch

Download all attachments as: .zip

Change History (2)

Changed 4 months ago by Richard Hazlewood <boost@…>

Attachment: boost_1_64_0-asio.patch added

One example patch

comment:1 Changed 4 months ago by mikealeonetti@…

The patch worked for me. Using gcc version 4.6.3 (Debian 4.6.3-14+rpi1) on Raspian. Fixed the compile issue.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain chris_kohlhoff.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.