[libc-commits] [libc] 69a0924 - [libc] Add missing cast in fputil	sqrt code
    Roland McGrath via libc-commits 
    libc-commits at lists.llvm.org
       
    Sat Mar 25 16:24:05 PDT 2023
    
    
  
Author: Roland McGrath
Date: 2023-03-25T16:23:48-07:00
New Revision: 69a0924fac6ffac748a277a27360f80e80cc9147
URL: https://github.com/llvm/llvm-project/commit/69a0924fac6ffac748a277a27360f80e80cc9147
DIFF: https://github.com/llvm/llvm-project/commit/69a0924fac6ffac748a277a27360f80e80cc9147.diff
LOG: [libc] Add missing cast in fputil sqrt code
A cast is necessary to avoid implicit narrowing warnings
when those are enabled.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D146886
Added: 
    
Modified: 
    libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
Removed: 
    
################################################################################
diff  --git a/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h b/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
index 328b02eec75ff..17a1c25bc6407 100644
--- a/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
+++ b/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
@@ -21,9 +21,9 @@ namespace fputil {
 namespace x86 {
 
 LIBC_INLINE void normalize(int &exponent, UInt128 &mantissa) {
-  const int shift =
+  const unsigned int shift = static_cast<unsigned int>(
       unsafe_clz(static_cast<uint64_t>(mantissa)) -
-      (8 * sizeof(uint64_t) - 1 - MantissaWidth<long double>::VALUE);
+      (8 * sizeof(uint64_t) - 1 - MantissaWidth<long double>::VALUE));
   exponent -= shift;
   mantissa <<= shift;
 }
        
    
    
More information about the libc-commits
mailing list