Boost C++ Libraries: Ticket #5904: Patch to suppress "unreachable code" warning from Visual Studio 2008/2010 (VC90/VC100) https://svn.boost.org/trac10/ticket/5904 <p> Probably as a result of ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3311" title="#3311: Bugs: Unintentionally unthrown exceptions (closed: fixed)">#3311</a>, Visual Studio correctly identifies unreachable code when instantiating a boost::iostreams::stream with a Device that doesn't support certain functionality (e.g. a write-only Sink). Since the relevant code is reachable for other kinds of Device, the simplest fix is to just suppress the warning. The equivalent warning for Borland is already suppressed in boost/iostreams/detail/config/disable_warnings.hpp. </p> <p> Code: </p> <pre class="wiki">#include &lt;deque&gt; #include &lt;boost/iostreams/stream.hpp&gt; #include &lt;boost/iostreams/device/back_inserter.hpp&gt; boost::iostreams::stream&lt; boost::iostreams::back_insert_device&lt; std::deque&lt; char &gt; &gt; &gt; s; </pre><p> Result (provided not /Od): </p> <pre class="wiki">1&gt;...\boost_1_47_0\boost\iostreams\detail\adapter\concept_adapter.hpp(77) : warning C4702: unreachable code 1&gt;...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(259) : warning C4702: unreachable code 1&gt;...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(260) : warning C4702: unreachable code 1&gt;...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(261) : warning C4702: unreachable code 1&gt;...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(263) : warning C4702: unreachable code 1&gt;...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(266) : warning C4702: unreachable code 1&gt;...\boost_1_47_0\boost\iostreams\detail\adapter\concept_adapter.hpp(95) : warning C4702: unreachable code 1&gt;...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(333) : warning C4702: unreachable code </pre><p> Patch for boost/iostreams/detail/config/disable_warnings.hpp: </p> <pre class="wiki">17a18 &gt; # pragma warning(disable:4702) // Unreachable code. </pre><p> Please would someone apply this for Boost 1.48.0? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5904 Trac 1.4.3 anonymous Mon, 19 Sep 2011 18:35:00 GMT owner changed https://svn.boost.org/trac10/ticket/5904#comment:1 https://svn.boost.org/trac10/ticket/5904#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Daniel James</span> to <span class="trac-author">No-Maintainer</span> </li> </ul> Ticket