From 77870cc80b1d104824c6781a2ce36b4e5bf4d16e Mon Sep 17 00:00:00 2001 From: root Date: Sat, 2 Nov 2024 20:38:03 -0400 Subject: [PATCH] Fix Wsign-conversion warnings --- source/utf8/core.h | 8 ++++---- source/utf8/unchecked.h | 6 +++--- tests/CMakeLists.txt | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/utf8/core.h b/source/utf8/core.h index 4494c53..627133c 100644 --- a/source/utf8/core.h +++ b/source/utf8/core.h @@ -215,7 +215,7 @@ namespace internal UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) - code_point += (*it) & 0x3f; + code_point = static_cast(code_point + ((*it) & 0x3f)); return UTF8_OK; } @@ -234,11 +234,11 @@ namespace internal UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) - code_point += (utf8::internal::mask8(*it) << 6) & 0xfff; + code_point = static_cast(code_point + ((utf8::internal::mask8(*it) << 6) & 0xfff)); UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) - code_point += (*it) & 0x3f; + code_point = static_cast(code_point + ((*it) & 0x3f)); return UTF8_OK; } @@ -327,7 +327,7 @@ namespace internal else if (is_lead_surrogate(first_word)) { const utfchar16_t second_word = *it++; if (is_trail_surrogate(second_word)) { - code_point = (first_word << 10) + second_word + SURROGATE_OFFSET; + code_point = static_cast(first_word << 10) + second_word + SURROGATE_OFFSET; return UTF8_OK; } else err = INCOMPLETE_SEQUENCE; diff --git a/source/utf8/unchecked.h b/source/utf8/unchecked.h index 65d4948..bf29178 100644 --- a/source/utf8/unchecked.h +++ b/source/utf8/unchecked.h @@ -115,15 +115,15 @@ namespace utf8 ++it; cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff); ++it; - cp += (*it) & 0x3f; + cp = static_cast(cp + ((*it) & 0x3f)); break; case 4: ++it; cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff); ++it; - cp += (utf8::internal::mask8(*it) << 6) & 0xfff; + cp = static_cast(cp + ((utf8::internal::mask8(*it) << 6) & 0xfff)); ++it; - cp += (*it) & 0x3f; + cp = static_cast(cp + ((*it) & 0x3f)); break; } ++it; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f8f5b36..f2bf1fc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,7 +11,7 @@ if (MSVC) add_compile_options(/W4) else() # additional warnings - add_compile_options(-Wall -Wextra -Wpedantic -Wconversion) + add_compile_options(-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion) endif() add_executable(negative negative.cpp)