[libc-commits] [PATCH] D146886: [libc] Add missing cast in fputil sqrt code

Roland McGrath via Phabricator via libc-commits libc-commits at lists.llvm.org
Sat Mar 25 14:31:55 PDT 2023


mcgrathr created this revision.
mcgrathr added reviewers: lntue, abrachet.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
mcgrathr requested review of this revision.

A cast is necessary to avoid implicit narrowing warnings
when those are enabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146886

Files:
  libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h


Index: libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
===================================================================
--- libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
+++ libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
@@ -21,9 +21,9 @@
 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;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146886.508344.patch
Type: text/x-patch
Size: 686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230325/f39177f7/attachment.bin>


More information about the libc-commits mailing list