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

via libc-commits libc-commits at lists.llvm.org
Sat Sep 20 09:33:19 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Maksim Levental (makslevental)

<details>
<summary>Changes</summary>

This test fails under -Werror=implicit-float-conversion (like in our pre-merge CI) because `dsqrtl` returns a double https://github.com/llvm/llvm-project/blob/2b937daa1310f7c17a03a0a4a7abf83149e1dc71/libc/src/__support/math/dsqrtl.h#L18

Fixes https://github.com/llvm/llvm-project/issues/159932

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


1 Files Affected:

- (modified) libc/test/shared/shared_math_test.cpp (+1-1) 


``````````diff
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 9e4d4d52e7f5e..bfff5ecb8cf81 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -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));
   EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::erff(0.0f));
   EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::exp10f(0.0f));
   EXPECT_FP_EQ(0x1p+0f, LIBC_NAMESPACE::shared::expf(0.0f));

``````````

</details>


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


More information about the libc-commits mailing list