[libc-commits] [libc] [libc][math] Fix -Wc++23-extensions warnings in erfcf16 and erff16. (PR #215613)

via libc-commits libc-commits at lists.llvm.org
Wed Aug 12 08:59:19 PDT 2026


================
@@ -134,17 +134,20 @@ LIBC_INLINE float16 erff16(float16 x) {
         return x;
       }
       // Inf -> returns 1.0 or -1.0
-      return is_neg ? -1.0f16 : 1.0f16;
+      static constexpr float16 ONE_F16 = fputil::cast<float16>(1.0f);
+      return is_neg ? -ONE_F16 : ONE_F16;
     }
 
+    // FIXME: Handle f16 constant emission without triggering -Wc++23-extensions
     return fputil::cast<float16>(is_neg ? -1.0f - xf * 0x1.0p-28f
                                         : 1.0f - xf * 0x1.0p-28f);
   }
 
   // Polynomial approximation:
   //   erf(x) ~ x * (c0 + c1 * x^2 + c2 * x^4 + ... + c7 * x^14)
 
-  int idx = static_cast<int>(xbits.abs().get_val() * 8.0f16);
+  static constexpr float16 EIGHT_F16 = fputil::cast<float16>(8.0f);
----------------
lntue wrote:

remove `static`

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


More information about the libc-commits mailing list