Boost C++ Libraries: Ticket #4859: boost/asio/detail/impl/socket_ops.ipp:122 produces "expression is always true" compile error on MS Visual Studio 2008 https://svn.boost.org/trac10/ticket/4859 <p> 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: </p> <pre class="wiki">boost/asio/detail/impl/socket_ops.ipp(122): error C4296: '&gt;=' : expression is always true </pre><p> This is associated with the following block of code: </p> <pre class="wiki"> // 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 &gt;= 0) return new_socket; </pre><p> socket_type is defined in socket_types.hpp, which on Windows is: </p> <pre class="wiki">typedef SOCKET socket_type; </pre><p> SOCKET is defined in winsock.h/winsock2.h as: </p> <pre class="wiki">typedef UINT_PTR SOCKET; </pre><p> 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. </p> <p> Also in: </p> <ul><li>branches/release/boost/asio/detail/impl/socket_ops.ipp @ 66173 </li><li>trunk/boost/asio/detail/impl/socket_ops.ipp @ 66611 </li></ul> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4859 Trac 1.4.3 Kris Nobes <kris.nobes@…> Tue, 16 Nov 2010 12:09:17 GMT attachment set https://svn.boost.org/trac10/ticket/4859 https://svn.boost.org/trac10/ticket/4859 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">check_against_invalid_socket.patch</span> </li> </ul> Ticket chris_kohlhoff Wed, 17 Nov 2010 09:52:03 GMT <link>https://svn.boost.org/trac10/ticket/4859#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4859#comment:1</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/66620" title="Merge from trunk. ........ r66613 | chris_kohlhoff | 2010-11-17 ...">[66620]</a>) Merge from trunk. ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/66613" title="Fixed a Windows-specific problem where failures from accept() are ...">r66613</a> | chris_kohlhoff | 2010-11-17 00:16:45 +1100 (Wed, 17 Nov 2010) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fixed a Windows-specific problem where failures from accept() are incorrectly treated as successes. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4859" title="#4859: Bugs: boost/asio/detail/impl/socket_ops.ipp:122 produces &#34;expression is ... (closed: fixed)">#4859</a>. </p> </blockquote> <p> ........ </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Wed, 17 Nov 2010 12:19:29 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4859#comment:2 https://svn.boost.org/trac10/ticket/4859#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket