[libc-commits] [libc] [libc] fix error: implicit conversion loses floating-point precision: 'double' to 'float' in shared_math_test.cpp (PR #159934)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Sat Sep 20 09:43:18 PDT 2025


================
@@ -57,7 +57,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
   EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::cosf(0.0f));
   EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::coshf(0.0f));
   EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::cospif(0.0f));
-  EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::dsqrtl(0.0f));
+  EXPECT_FP_EQ(0x0p+0f, (float)LIBC_NAMESPACE::shared::dsqrtl(0.0f));
----------------
jhuber6 wrote:

If it fixes the warning without the `f` constant then that's probably the better solution, since technically the double result could be within a float's ULP and get rounded to zero. Though the chances of that happening are quite slim.

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


More information about the libc-commits mailing list