Opened 9 years ago
Closed 8 years ago
#9548 closed Bugs (fixed)
Improper order of operations in function causing infinite recursive call
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | To Be Determined | Component: | asio |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: | gromer@… |
Description
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.
Change History (2)
comment:1 by , 9 years ago
Cc: | added |
---|
comment:2 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Fixed on 'develop' in 9e757605709cace0fc048ad284b2d6aa3ae784ac.
Merged to 'master' in 4e1e7d731fcc5c0104567856de476f7ce8806d72.