[Boost-bugs] [Boost C++ Libraries] #11989: gcc 5.3 optimizer mangles non_blocking_recvfrom

Subject: [Boost-bugs] [Boost C++ Libraries] #11989: gcc 5.3 optimizer mangles non_blocking_recvfrom
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-02-16 12:48:22

#11989: gcc 5.3 optimizer mangles non_blocking_recvfrom
 Reporter: tmark@… | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost 1.58.0 | Severity: Optimization
 Keywords: |
 Our Kea project uses boost::asio. When compiled with gcc 5.3.1 and -O2,
 the optimizer is incorrectly removing tests, against a variable which can
 be changed, from one of the boost::asio functions.

 The affected function is:

 bool non_blocking_recvfrom(socket_type s,
     buf* bufs, size_t count, int flags,
     socket_addr_type* addr, std::size_t* addrlen,
     boost::system::error_code& ec, size_t& bytes_transferred)

 in the file:


 where the tests for "ec" shown below are optmized out:


     // Retry operation if interrupted by signal.
     if (ec == boost::asio::error::interrupted)

     // Check if we need to run the operation again.
     if (ec == boost::asio::error::would_block
         || ec == boost::asio::error::try_again)
       return false;


 This causes the function to always return true.

 I have also opened a ticket with the good people at GCC, ticket #69789.
 This occurred with Boost 1.58, though I suspect the issue is present in
 1.60 as the code for the function appears to be unchanged.

 Additional information:

 1. gcc --version output:

 Using built-in specs.
 Target: x86_64-redhat-linux
 Configured with: ../configure --enable-bootstrap --enable-
 languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr
 --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared
 --enable-threads=posix --enable-checking=release --enable-multilib --with-
 system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-
 gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu
 --enable-plugin --enable-initfini-array --disable-libgcj --with-isl
 --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-
 arch_32=i686 --build=x86_64-redhat-linux
 Thread model: posix
 gcc version 5.3.1 20151207 (Red Hat 5.3.1-2) (GCC)

 2. OS info:

 Linux fedora23-64-1 4.3.4-300.fc23.x86_64 #1 SMP Mon Jan 25 13:39:23 UTC
 2016 x86_64 x86_64 x86_64 GNU/Linux

 3. Compiler command line:

 g++ -DHAVE_CONFIG_H -I. -I../../../.. -I../../../../src/lib
 -I../../../../src/lib -DTEST_DATA_DIR=\"./testdata\"
 -I/opt/gtest/gtest-1.7.0 -I/opt/gtest/gtest-1.7.0/include -DOS_LINUX
 -I../../../../ext/coroutine -DBOOST_ASIO_HEADER_ONLY
 -DBOOST_SYSTEM_NO_DEPRECATED -Wall -Wextra -Wnon-virtual-dtor -Wwrite-
 strings -Woverloaded-virtual -Wno-sign-compare -pthread -Werror -fPIC
 -Wno-missing-field-initializers -Wno-unused-parameter -g -O2 -save-temps
 -MT run_unittests-udp_socket_unittest.o -MD -MP -MF .deps/run_unittests-
 udp_socket_unittest.Tpo -c -o run_unittests-udp_socket_unittest.o `test -f
 'udp_socket_unittest.cc' || echo './'`udp_socket_unittest.cc

Ticket URL: <https://svn.boost.org/trac/boost/ticket/11989>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC