[Boost-bugs] [Boost C++ Libraries] #4573: boost/asio/detail/impl/socket_ops.ipp:315: int 'result' shadows previous 'result', declared at line 278

Subject: [Boost-bugs] [Boost C++ Libraries] #4573: boost/asio/detail/impl/socket_ops.ipp:315: int 'result' shadows previous 'result', declared at line 278
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-08-19 21:16:50


#4573: boost/asio/detail/impl/socket_ops.ipp:315: int 'result' shadows previous
'result', declared at line 278
------------------------------+---------------------------------------------
 Reporter: anonymous | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------------------------
 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4573>
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:04 UTC