[Boost-bugs] [Boost C++ Libraries] #4859: boost/asio/detail/impl/socket_ops.ipp:122 produces "expression is always true" compile error on MS Visual Studio 2008

Subject: [Boost-bugs] [Boost C++ Libraries] #4859: boost/asio/detail/impl/socket_ops.ipp:122 produces "expression is always true" compile error on MS Visual Studio 2008
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-11-16 12:08:12


#4859: boost/asio/detail/impl/socket_ops.ipp:122 produces "expression is always
true" compile error on MS Visual Studio 2008
--------------------------------------------------+-------------------------
 Reporter: Kris Nobes <kris.nobes@…> | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost Release Branch | Severity: Problem
 Keywords: |
--------------------------------------------------+-------------------------
 In boost/asio/detail/impl/socket_ops.ipp from boost_1_45_0_beta1 built
 with Microsoft Visual C++ compiler 2008, the following error is produced:

 {{{
 boost/asio/detail/impl/socket_ops.ipp(122): error C4296: '>=' : expression
 is always true
 }}}

 This is associated with the following block of code:
 {{{
     // Try to complete the operation without blocking.
     socket_type new_socket = socket_ops::accept(s, addr, addrlen, ec);

     // Check if operation succeeded.
     if (new_socket >= 0)
       return new_socket;
 }}}

 socket_type is defined in socket_types.hpp, which on Windows is:
 {{{
 typedef SOCKET socket_type;
 }}}
 SOCKET is defined in winsock.h/winsock2.h as:
 {{{
 typedef UINT_PTR SOCKET;
 }}}

 It would seem that new_socket should be compared to invalid_socket
 (defined in socket_types.hpp, line 86), which is the same test performed
 elsewhere in this file. The patch attached will produce this change but
 I'd like confirmation that the problem and solution are valid.

 Also in:
 * branches/release/boost/asio/detail/impl/socket_ops.ipp @ 66173
 * trunk/boost/asio/detail/impl/socket_ops.ipp @ 66611

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4859>
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:04 UTC