-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[libc] Add missing casts in StrtolTest #119054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The a0c4f85 change replaced the local int_to_b36_char function returning `char` with uses of the __support function of the same name that returns `int`. The uses of the old local function lacked the casts that all other uses of the shared function of the same name had. Add them.
@llvm/pr-subscribers-libc Author: Roland McGrath (frobtech) ChangesThe a0c4f85 change replaced the Full diff: https://github.com/llvm/llvm-project/pull/119054.diff 1 Files Affected:
diff --git a/libc/test/src/stdlib/StrtolTest.h b/libc/test/src/stdlib/StrtolTest.h
index 6cfaddcbedeb6a..ed302f14d03ef4 100644
--- a/libc/test/src/stdlib/StrtolTest.h
+++ b/libc/test/src/stdlib/StrtolTest.h
@@ -200,8 +200,8 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
char small_string[4] = {'\0', '\0', '\0', '\0'};
for (int base = 2; base <= 36; ++base) {
for (int first_digit = 0; first_digit <= 36; ++first_digit) {
- small_string[0] =
- LIBC_NAMESPACE::internal::int_to_b36_char(first_digit);
+ small_string[0] = static_cast<char>(
+ LIBC_NAMESPACE::internal::int_to_b36_char(first_digit));
if (first_digit < base) {
LIBC_NAMESPACE::libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base),
@@ -217,11 +217,11 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
for (int base = 2; base <= 36; ++base) {
for (int first_digit = 0; first_digit <= 36; ++first_digit) {
- small_string[0] =
- LIBC_NAMESPACE::internal::int_to_b36_char(first_digit);
+ small_string[0] = static_cast<char>(
+ LIBC_NAMESPACE::internal::int_to_b36_char(first_digit));
for (int second_digit = 0; second_digit <= 36; ++second_digit) {
- small_string[1] =
- LIBC_NAMESPACE::internal::int_to_b36_char(second_digit);
+ small_string[1] = static_cast<char>(
+ LIBC_NAMESPACE::internal::int_to_b36_char(second_digit));
if (first_digit < base && second_digit < base) {
LIBC_NAMESPACE::libc_errno = 0;
ASSERT_EQ(
@@ -244,14 +244,14 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
for (int base = 2; base <= 36; ++base) {
for (int first_digit = 0; first_digit <= 36; ++first_digit) {
- small_string[0] =
- LIBC_NAMESPACE::internal::int_to_b36_char(first_digit);
+ small_string[0] = static_cast<char>(
+ LIBC_NAMESPACE::internal::int_to_b36_char(first_digit));
for (int second_digit = 0; second_digit <= 36; ++second_digit) {
- small_string[1] =
- LIBC_NAMESPACE::internal::int_to_b36_char(second_digit);
+ small_string[1] = static_cast<char>(
+ LIBC_NAMESPACE::internal::int_to_b36_char(second_digit));
for (int third_digit = 0; third_digit <= limit; ++third_digit) {
- small_string[2] =
- LIBC_NAMESPACE::internal::int_to_b36_char(third_digit);
+ small_string[2] = static_cast<char>(
+ LIBC_NAMESPACE::internal::int_to_b36_char(third_digit));
if (first_digit < base && second_digit < base &&
third_digit < base) {
|
Was this exposed by a truncation warning set downstream that we should perhaps be setting in our cmakelists upstream? |
The Fuchsia build uses fairly strict warnings. The error cites |
LLVM has a neat utility called In this case, the group hierarchy for
(so It's probably worthwhile for us to set at least |
err libc/cmake/modules/LLVMLibCCompileOptionRules.cmakeL161 sets |
err libc/cmake/modules/LLVMLibCCompileOptionRules.cmakeL237 sets -Wconversion, but it's commented out! Let me do some git archaeology to better understand why. |
Filed #119281. |
The a0c4f85 change replaced the
local int_to_b36_char function returning
char
with uses of the__support function of the same name that returns
int
. The usesof the old local function lacked the casts that all other uses of
the shared function of the same name had. Add them.