Boost C++ Libraries: Ticket #9548: Improper order of operations in function causing infinite recursive call https://svn.boost.org/trac10/ticket/9548 <p> In also/ip/resolver_query_base.hpp, the enum flags has an overloaded function for the ~ operator. Here is the code below: </p> <blockquote> <p> friend flags operator~(flags x) { </p> <blockquote> <p> return static_cast&lt;flags&gt;(static_cast&lt;unsigned int&gt;(~x)); </p> </blockquote> <p> } </p> </blockquote> <p> Note that the ~ in the function is applied to x, not the static_cast. This will call the overloaded operator again. The proper fix is: </p> <blockquote> <p> friend flags operator~(flags x) { </p> <blockquote> <p> return static_cast&lt;flags&gt;(~static_cast&lt;unsigned int&gt;(x)); </p> </blockquote> <p> } </p> </blockquote> <p> which uses the builtin ~ operator for unsigned int. This was detected by Clang's new warning -Winfinite-recursion. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9548 Trac 1.4.3 gromer@… Tue, 07 Jan 2014 00:37:55 GMT cc set https://svn.boost.org/trac10/ticket/9548#comment:1 https://svn.boost.org/trac10/ticket/9548#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">gromer@…</span> added </li> </ul> Ticket chris_kohlhoff Mon, 05 May 2014 06:46:10 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9548#comment:2 https://svn.boost.org/trac10/ticket/9548#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> <p> Fixed on 'develop' in <a class="ext-link" href="https://github.com/boostorg/asio/commit/9e757605709cace0fc048ad284b2d6aa3ae784ac"><span class="icon">​</span>9e757605709cace0fc048ad284b2d6aa3ae784ac</a>. </p> <p> Merged to 'master' in <a class="ext-link" href="https://github.com/boostorg/asio/commit/4e1e7d731fcc5c0104567856de476f7ce8806d72"><span class="icon">​</span>4e1e7d731fcc5c0104567856de476f7ce8806d72</a>. </p> Ticket