[libc-commits] [libc] 63c219b - [libc][math] Fixed Hypotbf16 build failure. (#186415)

via libc-commits libc-commits at lists.llvm.org
Fri Mar 13 09:10:39 PDT 2026


Author: Zorojuro
Date: 2026-03-13T12:10:31-04:00
New Revision: 63c219b8a866d799de28bb48a23ec32d868c2301

URL: https://github.com/llvm/llvm-project/commit/63c219b8a866d799de28bb48a23ec32d868c2301
DIFF: https://github.com/llvm/llvm-project/commit/63c219b8a866d799de28bb48a23ec32d868c2301.diff

LOG: [libc][math] Fixed Hypotbf16 build failure. (#186415)

Ref from the build failure in hypotbf16
```CPP
project/libc/src/__support/math/hypotbf16.h:22:33:   required from here
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/FPUtil/Hypot.h:221:44: error: conversion from ‘int’ to ‘StorageType’ {aka ‘short unsigned int’} may change value [-Werror=conversion]
  221 |     r = static_cast<StorageType>((r << 1)) +
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
  222 |         ((tail_bits & current_bit) ? 1 : 0);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
cc1plus: all warnings being treated as errors
```

This PR intends to fix that by adding static_cast

Added: 
    

Modified: 
    libc/src/__support/FPUtil/Hypot.h

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/FPUtil/Hypot.h b/libc/src/__support/FPUtil/Hypot.h
index e23f8b52d8220..292140065c754 100644
--- a/libc/src/__support/FPUtil/Hypot.h
+++ b/libc/src/__support/FPUtil/Hypot.h
@@ -218,8 +218,8 @@ LIBC_INLINE T hypot(T x, T y) {
 
   for (StorageType current_bit = leading_one >> 1; current_bit;
        current_bit >>= 1) {
-    r = static_cast<StorageType>((r << 1)) +
-        ((tail_bits & current_bit) ? 1 : 0);
+    r = static_cast<StorageType>((r << 1) +
+                                 ((tail_bits & current_bit) ? 1 : 0));
     StorageType tmp = static_cast<StorageType>((y_new << 1)) +
                       current_bit; // 2*y_new(n - 1) + 2^(-n)
     if (r >= tmp) {


        


More information about the libc-commits mailing list