Skip to content

Commit

Permalink
Fix Wsign-conversion warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Nov 3, 2024
1 parent cd191b6 commit 77870cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions source/utf8/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ namespace internal

UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)

code_point += (*it) & 0x3f;
code_point = static_cast<utfchar32_t>(code_point + ((*it) & 0x3f));

return UTF8_OK;
}
Expand All @@ -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<utfchar32_t>(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<utfchar32_t>(code_point + ((*it) & 0x3f));

return UTF8_OK;
}
Expand Down Expand Up @@ -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<utfchar32_t>(first_word << 10) + second_word + SURROGATE_OFFSET;
return UTF8_OK;
} else
err = INCOMPLETE_SEQUENCE;
Expand Down
6 changes: 3 additions & 3 deletions source/utf8/unchecked.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ namespace utf8
++it;
cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
++it;
cp += (*it) & 0x3f;
cp = static_cast<utfchar32_t>(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<utfchar32_t>(cp + ((utf8::internal::mask8(*it) << 6) & 0xfff));
++it;
cp += (*it) & 0x3f;
cp = static_cast<utfchar32_t>(cp + ((*it) & 0x3f));
break;
}
++it;
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 77870cc

Please sign in to comment.