Modify

Ticket #4859 (closed Bugs: fixed)

Opened 3 years ago

Last modified 3 years ago

boost/asio/detail/impl/socket_ops.ipp:122 produces "expression is always true" compile error on MS Visual Studio 2008

Reported by: Kris Nobes <kris.nobes@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost Release Branch Severity: Problem
Keywords: Cc:

Description

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

Attachments

check_against_invalid_socket.patch Download (423 bytes) - added by Kris Nobes <kris.nobes@…> 3 years ago.

Change History

Changed 3 years ago by Kris Nobes <kris.nobes@…>

comment:1 Changed 3 years ago by chris_kohlhoff

(In [66620]) Merge from trunk. ........

r66613 | chris_kohlhoff | 2010-11-17 00:16:45 +1100 (Wed, 17 Nov 2010) | 2 lines

Fixed a Windows-specific problem where failures from accept() are incorrectly treated as successes. Refs #4859.

........

comment:2 Changed 3 years ago by chris_kohlhoff

  • Status changed from new to closed
  • Resolution set to fixed
View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


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

 
Note: See TracTickets for help on using tickets.