[libc-commits] [libc] [libc] Fix recently introduced integer-type warnings (PR #125864)

Simon Tatham via libc-commits libc-commits at lists.llvm.org
Wed Feb 5 07:57:41 PST 2025


================
@@ -604,7 +604,7 @@ approx_reciprocal(const DyadicFloat<Bits> &a) {
   // of correct bits in x' is double the number in x.
 
   // An initial approximation to the reciprocal
-  DyadicFloat<Bits> x(Sign::POS, -32 - a.exponent - Bits,
+  DyadicFloat<Bits> x(Sign::POS, -32 - a.exponent - int(Bits),
----------------
statham-arm wrote:

It's true that there's no hard guarantee that nobody will instantiate the `DyadicFloat` template with `Bits` bigger than 2^32. But there's nothing we can do about it if they do, because the exponent of a `DyadicFloat` _is_ an int, so division of one of those just won't work. Also, there's no possible reason to make a float that large in the middle of a libc function – that's more memory than some target platforms even _have_, and the ones that do have that much memory would never be expecting an allocation that size as a side effect of calling into the standard library.

https://github.com/llvm/llvm-project/pull/125864


More information about the libc-commits mailing list