diff --git a/include/proxy/v4/detail/core.h b/include/proxy/v4/detail/core.h index 7ed3a24..213c2f6 100644 --- a/include/proxy/v4/detail/core.h +++ b/include/proxy/v4/detail/core.h @@ -823,6 +823,13 @@ operand_t get_operand(proxy_accessor p) { return *std::forward>(ptr); } } + +// When a dispatch always throws, MSVC may incorrectly warn about unreachable +// code (C4702). Disable the warning for invoke_dispatch(). +#if defined(_MSC_VER) && !defined(__clang__) +#pragma warning(push) +#pragma warning(disable : 4702) +#endif // defined(_MSC_VER) && !defined(__clang__) template R invoke_dispatch(Args&&... args) { if constexpr (std::is_void_v) { @@ -831,6 +838,9 @@ R invoke_dispatch(Args&&... args) { return D()(std::forward(args)...); } } +#if defined(_MSC_VER) && !defined(__clang__) +#pragma warning(pop) +#endif // defined(_MSC_VER) && !defined(__clang__) template R reinterpret_invoke(proxy_accessor self, Args&&... args) { diff --git a/tests/proxy_invocation_tests.cpp b/tests/proxy_invocation_tests.cpp index 9b4a758..6c7b911 100644 --- a/tests/proxy_invocation_tests.cpp +++ b/tests/proxy_invocation_tests.cpp @@ -14,15 +14,9 @@ #include #include #include -#if defined(_MSC_VER) && !defined(__clang__) -#pragma warning(push) -#pragma warning( \ - disable : 4702) // False alarm from MSVC: warning C4702: unreachable code -#endif // defined(_MSC_VER) && !defined(__clang__) + #include -#if defined(_MSC_VER) && !defined(__clang__) -#pragma warning(pop) -#endif // defined(_MSC_VER) && !defined(__clang__) + #include "utils.h" namespace proxy_invocation_tests_detail { diff --git a/tests/proxy_regression_tests.cpp b/tests/proxy_regression_tests.cpp index 70f4a50..48d5e1c 100644 --- a/tests/proxy_regression_tests.cpp +++ b/tests/proxy_regression_tests.cpp @@ -3,15 +3,7 @@ // Licensed under the MIT License. #include -#if defined(_MSC_VER) && !defined(__clang__) -#pragma warning(push) -#pragma warning( \ - disable : 4702) // False alarm from MSVC: warning C4702: unreachable code -#endif // defined(_MSC_VER) && !defined(__clang__) #include -#if defined(_MSC_VER) && !defined(__clang__) -#pragma warning(pop) -#endif // defined(_MSC_VER) && !defined(__clang__) #include namespace proxy_regression_tests_detail {