Opened 11 years ago

Last modified 11 years ago

#5904 new Patches

Patch to suppress "unreachable code" warning from Visual Studio 2008/2010 (VC90/VC100)

Reported by: gareth.sylvester-bradley@… Owned by: No-Maintainer
Milestone: Boost 1.48.0 Component: iostreams
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

Probably as a result of ticket #3311, 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.

Code:

#include <deque>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/back_inserter.hpp>

boost::iostreams::stream< boost::iostreams::back_insert_device< std::deque< char > > > s;

Result (provided not /Od):

1>...\boost_1_47_0\boost\iostreams\detail\adapter\concept_adapter.hpp(77) : warning C4702: unreachable code
1>...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(259) : warning C4702: unreachable code
1>...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(260) : warning C4702: unreachable code
1>...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(261) : warning C4702: unreachable code
1>...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(263) : warning C4702: unreachable code
1>...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(266) : warning C4702: unreachable code
1>...\boost_1_47_0\boost\iostreams\detail\adapter\concept_adapter.hpp(95) : warning C4702: unreachable code
1>...\boost_1_47_0\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(333) : warning C4702: unreachable code

Patch for boost/iostreams/detail/config/disable_warnings.hpp:

17a18
> # pragma warning(disable:4702)    // Unreachable code.

Please would someone apply this for Boost 1.48.0?

Change History (1)

comment:1 by anonymous, 11 years ago

Owner: changed from Daniel James to No-Maintainer
Note: See TracTickets for help on using tickets.