[libc-commits] [PATCH] D156812: [libc][NFC] Fix str_to_float and uint warnings

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Aug 1 10:24:33 PDT 2023


michaelrj created this revision.
michaelrj added reviewers: lntue, mcgrathr, sivachandra.
Herald added projects: libc-project, All.
Herald added a subscriber: libc-commits.
michaelrj requested review of this revision.

More Wconversion and Wno-sign-conversion warning fixes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156812

Files:
  libc/src/__support/UInt.h
  libc/src/__support/str_to_float.h


Index: libc/src/__support/str_to_float.h
===================================================================
--- libc/src/__support/str_to_float.h
+++ libc/src/__support/str_to_float.h
@@ -1196,7 +1196,7 @@
             if (strtoint_result.has_error()) {
               error = strtoint_result.error;
             }
-            nan_mantissa = strtoint_result.value;
+            nan_mantissa = static_cast<BitsType>(strtoint_result.value);
             if (src[left_paren + 1 + strtoint_result.parsed_len] != ')')
               nan_mantissa = 0;
           }
Index: libc/src/__support/UInt.h
===================================================================
--- libc/src/__support/UInt.h
+++ libc/src/__support/UInt.h
@@ -381,7 +381,7 @@
 
     BigInt<Bits, Signed> quotient(0);
     BigInt<Bits, Signed> subtractor = other;
-    int cur_bit = subtractor.clz() - this->clz();
+    int cur_bit = static_cast<int>(subtractor.clz() - this->clz());
     subtractor.shift_left(cur_bit);
 
     for (; cur_bit >= 0 && *this > 0; --cur_bit, subtractor.shift_right(1)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156812.546120.patch
Type: text/x-patch
Size: 1067 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230801/c80eabe1/attachment.bin>


More information about the libc-commits mailing list