Skip to content

Commit

Permalink
Fix unreachable code warning in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtum committed Oct 26, 2024
1 parent d1111ca commit 0608d6c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
16 changes: 7 additions & 9 deletions include/boost/beast/core/impl/buffers_cat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@ class buffers_cat_view<Buffer>
#define BOOST_BEAST_LOGIC_ERROR(s) \
{ \
BOOST_THROW_EXCEPTION(std::logic_error((s))); \
BOOST_BEAST_UNREACHABLE(); \
}

#define BOOST_BEAST_LOGIC_ERROR_RETURN(s, v) \
{ \
BOOST_THROW_EXCEPTION(std::logic_error((s))); \
return v; \
}

#else
Expand All @@ -94,13 +92,6 @@ struct buffers_cat_view_iterator_base
{
char unused = 0; // make g++8 happy

net::mutable_buffer
operator*() const
{
BOOST_BEAST_LOGIC_ERROR_RETURN(
"Dereferencing a one-past-the-end iterator", {});
}

operator bool() const noexcept
{
return true;
Expand Down Expand Up @@ -189,6 +180,13 @@ class buffers_cat_view<Bn...>::const_iterator
"Dereferencing a default-constructed iterator", {});
}

reference
operator()(mp11::mp_size_t<sizeof...(Bn)+1>)
{
BOOST_BEAST_LOGIC_ERROR_RETURN(
"Dereferencing a one-past-the-end iterator", {});
}

template<class I>
reference operator()(I)
{
Expand Down
12 changes: 11 additions & 1 deletion test/beast/core/saved_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
// Official repository: https://github.com/boostorg/beast
//

#include <boost/config.hpp>

#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4702) // unreachable code
#endif

// Test that header file is self-contained.
#include <boost/beast/core/saved_handler.hpp>
#include <boost/asio/bind_cancellation_slot.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <stdexcept>

namespace boost {
namespace beast {
Expand Down Expand Up @@ -220,3 +226,7 @@ BEAST_DEFINE_TESTSUITE(beast,core,saved_handler);

} // beast
} // boost

#ifdef BOOST_MSVC
#pragma warning(pop)
#endif

0 comments on commit 0608d6c

Please sign in to comment.