From 02926760ed0c008837000ffaf1e44d3e86c1bbc3 Mon Sep 17 00:00:00 2001 From: rstein Date: Thu, 9 Nov 2023 10:24:01 +0100 Subject: [PATCH] suppresses `-Wuseless-cast` for static_cast('\0') MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit needed in case 'char_type' is 'char' (common on Linux but rare on Windows?) ```text [..]/magic_enum.hpp:275:114: warning: useless cast to type ‘using magic_enum::char_type = using std::basic_string_view::value_type = char’ {aka ‘char’} [-Wuseless-cast] 275 | constexpr static_str(string_view str, std::integer_sequence) noexcept : chars_{str[I]..., static_cast('\0')} {} | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` --- include/magic_enum.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index 53e01c0a1..79f445553 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -69,9 +69,11 @@ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-warning-option" # pragma clang diagnostic ignored "-Wenum-constexpr-conversion" +# pragma clang diagnostic ignored "-Wuseless-cast" // suppresses 'static_cast('\0')' for char_type = char (common on Linux). #elif defined(__GNUC__) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // May be used uninitialized 'return {};'. +# pragma GCC diagnostic ignored "-Wuseless-cast" // suppresses 'static_cast('\0')' for char_type = char (common on Linux). #elif defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 26495) // Variable 'static_str::chars_' is uninitialized.