Ticket #4573 (closed Bugs: fixed)
boost/asio/detail/impl/socket_ops.ipp:315: int 'result' shadows previous 'result', declared at line 278
|Reported by:||anonymous||Owned by:||chris_kohlhoff|
|Milestone:||To Be Determined||Component:||asio|
As of r64932 file boost/asio/detail/impl/socket_ops.ipp at function close, there is a declaration of 'int result' on line 315 that shadows a previous declaration of 'int result' on line 278. This causes warning C6246 from the Microsoft code analysis tool PREfast, because shadowing can often cause bugs or reduce maintainability. From inspection of the code, this particular construct guarantees that boost::asio::detail::socket_ops::close always returns 0, since the result initialized with a real value goes out of scope and the return statement then reads the result that was default-initialized to 0.
Some call sites test the value of close, but most do not. In reactive_socket_service_base.ipp:67, the return value of close is used to decide whether to reconstruct the impl.