Subject: [Boost-bugs] [Boost C++ Libraries] #9548: Improper order of operations in function causing infinite recursive call
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-01-07 00:02:17
#9548: Improper order of operations in function causing infinite recursive call
------------------------------+----------------------------
Reporter: rtrieu@⦠| Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
Version: Boost 1.55.0 | Severity: Problem
Keywords: |
------------------------------+----------------------------
In also/ip/resolver_query_base.hpp, the enum flags has an overloaded
function for the ~ operator. Here is the code below:
friend flags operator~(flags x)
{
return static_cast<flags>(static_cast<unsigned int>(~x));
}
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:
friend flags operator~(flags x)
{
return static_cast<flags>(~static_cast<unsigned int>(x));
}
which uses the builtin ~ operator for unsigned int. This was detected by
Clang's new warning -Winfinite-recursion.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9548> 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:15 UTC