Skip to content

[libc] Fix compilation error on targets without 128-bit int types #97039

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

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

overmighty
Copy link
Member

@llvmbot llvmbot added the libc label Jun 28, 2024
@overmighty
Copy link
Member Author

cc @lntue @michaelrj-google

@llvmbot
Copy link
Member

llvmbot commented Jun 28, 2024

@llvm/pr-subscribers-libc

Author: OverMighty (overmighty)

Changes

See Buildbot failures:


Full diff: https://github.com/llvm/llvm-project/pull/97039.diff

2 Files Affected:

  • (modified) libc/src/__support/high_precision_decimal.h (+2-1)
  • (modified) libc/test/src/__support/math_extras_test.cpp (+1-1)
diff --git a/libc/src/__support/high_precision_decimal.h b/libc/src/__support/high_precision_decimal.h
index 2c5a349e4495e..6a22554165014 100644
--- a/libc/src/__support/high_precision_decimal.h
+++ b/libc/src/__support/high_precision_decimal.h
@@ -409,7 +409,8 @@ class HighPrecisionDecimal {
       result *= 10;
       ++cur_digit;
     }
-    return result + this->should_round_up(this->decimal_point, round);
+    return result + static_cast<unsigned int>(
+                        this->should_round_up(this->decimal_point, round));
   }
 
   // Extra functions for testing.
diff --git a/libc/test/src/__support/math_extras_test.cpp b/libc/test/src/__support/math_extras_test.cpp
index 0047888965177..9f9036b9d5cdf 100644
--- a/libc/test/src/__support/math_extras_test.cpp
+++ b/libc/test/src/__support/math_extras_test.cpp
@@ -102,7 +102,7 @@ TYPED_TEST(LlvmLibcBitTest, CountZeros, UnsignedTypesNoBigInt) {
 }
 
 using UnsignedTypes = testing::TypeList<
-#if defined(__SIZEOF_INT128__)
+#if defined(LIBC_TYPES_HAS_INT128)
     __uint128_t,
 #endif
     unsigned char, unsigned short, unsigned int, unsigned long,

@lntue lntue merged commit 7f68675 into llvm:main Jun 28, 2024
6 of 7 checks passed
Comment on lines 104 to 106
using UnsignedTypes = testing::TypeList<
#if defined(__SIZEOF_INT128__)
#if defined(LIBC_TYPES_HAS_INT128)
__uint128_t,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I caught this as I tried to reproduce what was happening on the failed Buildbot builds by just not defining LIBC_TYPES_HAS_INT128. It won't cause a compilation error on real builds where 128-bit int types are either really available or they're not. This is basically a cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants