[libc-commits] [libc] [libc] Fix compilation errors thrown by GCC (PR #112351)

via libc-commits libc-commits at lists.llvm.org
Tue Oct 15 05:31:09 PDT 2024


https://github.com/overmighty created https://github.com/llvm/llvm-project/pull/112351

None

>From 1b188933dfbced50533172df874ae68248550d34 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Tue, 15 Oct 2024 14:27:36 +0200
Subject: [PATCH] [libc] Fix compilation errors thrown by GCC

---
 libc/src/__support/str_to_integer.h | 3 ++-
 libc/src/math/generic/exp2m1f16.cpp | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libc/src/__support/str_to_integer.h b/libc/src/__support/str_to_integer.h
index ea17178c6afb6a..c8d02434c89ce2 100644
--- a/libc/src/__support/str_to_integer.h
+++ b/libc/src/__support/str_to_integer.h
@@ -115,7 +115,8 @@ strtointeger(const char *__restrict src, int base,
                    : cpp::numeric_limits<T>::max();
   ResultType const abs_max =
       (is_positive ? cpp::numeric_limits<T>::max() : NEGATIVE_MAX);
-  ResultType const abs_max_div_by_base = abs_max / base;
+  ResultType const abs_max_div_by_base =
+      static_cast<ResultType>(abs_max / base);
 
   while (src_cur < src_len && isalnum(src[src_cur])) {
     int cur_digit = b36_char_to_int(src[src_cur]);
diff --git a/libc/src/math/generic/exp2m1f16.cpp b/libc/src/math/generic/exp2m1f16.cpp
index e6c57d730e3c2d..6a1cd2328a050e 100644
--- a/libc/src/math/generic/exp2m1f16.cpp
+++ b/libc/src/math/generic/exp2m1f16.cpp
@@ -126,7 +126,7 @@ LLVM_LIBC_FUNCTION(float16, exp2m1f16, (float16 x)) {
       case FE_DOWNWARD:
         return FPBits::one(Sign::NEG).get_val();
       default:
-        return -0x1.ffcp-1;
+        return fputil::cast<float16>(-0x1.ffcp-1);
       }
     }
 



More information about the libc-commits mailing list