From 4ea56c4b39b7465fe0a970c2efc05290b5b088b6 Mon Sep 17 00:00:00 2001 From: Mohammad Nejati Date: Fri, 25 Oct 2024 09:37:27 +0000 Subject: [PATCH] Fix unreachable code warning in tests --- include/boost/beast/core/impl/buffers_cat.hpp | 16 +++++++--------- test/beast/core/saved_handler.cpp | 12 +++++++++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/boost/beast/core/impl/buffers_cat.hpp b/include/boost/beast/core/impl/buffers_cat.hpp index 35d1a34d..98c47758 100644 --- a/include/boost/beast/core/impl/buffers_cat.hpp +++ b/include/boost/beast/core/impl/buffers_cat.hpp @@ -61,13 +61,11 @@ public: #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 @@ -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; @@ -189,6 +180,13 @@ private: "Dereferencing a default-constructed iterator", {}); } + reference + operator()(mp11::mp_size_t) + { + BOOST_BEAST_LOGIC_ERROR_RETURN( + "Dereferencing a one-past-the-end iterator", {}); + } + template reference operator()(I) { diff --git a/test/beast/core/saved_handler.cpp b/test/beast/core/saved_handler.cpp index 81fa8467..d1816d24 100644 --- a/test/beast/core/saved_handler.cpp +++ b/test/beast/core/saved_handler.cpp @@ -7,11 +7,17 @@ // Official repository: https://github.com/boostorg/beast // +#include + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4702) // unreachable code +#endif + // Test that header file is self-contained. #include #include #include -#include namespace boost { namespace beast { @@ -220,3 +226,7 @@ BEAST_DEFINE_TESTSUITE(beast,core,saved_handler); } // beast } // boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif