about summary refs log tree commit diff
path: root/math/w_j0f_compat.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-12-20 15:00:24 -0800
committerH.J. Lu <hjl.tools@gmail.com>2021-12-23 06:45:47 -0800
commit6e30181b4a3ab6c56da0378b65f4d60504982300 (patch)
tree74d8259530d69b3a855ef67da9df377fae0f658c /math/w_j0f_compat.c
parenta4b413135535c83a25a8b2d661bf1c75006dfa15 (diff)
downloadglibc-6e30181b4a3ab6c56da0378b65f4d60504982300.tar.gz
glibc-6e30181b4a3ab6c56da0378b65f4d60504982300.tar.xz
glibc-6e30181b4a3ab6c56da0378b65f4d60504982300.zip
math: Properly cast X_TLOSS to float [BZ #28713]
Add

 #define AS_FLOAT_CONSTANT_1(x) x##f
 #define AS_FLOAT_CONSTANT(x) AS_FLOAT_CONSTANT_1(x)

to cast X_TLOSS to float at compile-time to fix:

FAIL: math/test-float-j0
FAIL: math/test-float-jn
FAIL: math/test-float-y0
FAIL: math/test-float-y1
FAIL: math/test-float-yn
FAIL: math/test-float32-j0
FAIL: math/test-float32-jn
FAIL: math/test-float32-y0
FAIL: math/test-float32-y1
FAIL: math/test-float32-yn

when compiling with GCC 12.

Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Diffstat (limited to 'math/w_j0f_compat.c')
-rw-r--r--math/w_j0f_compat.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/math/w_j0f_compat.c b/math/w_j0f_compat.c
index d375f3bfb0..3257533596 100644
--- a/math/w_j0f_compat.c
+++ b/math/w_j0f_compat.c
@@ -27,7 +27,8 @@
 float
 __j0f (float x)
 {
-  if (__builtin_expect (isgreater (fabsf (x), (float) X_TLOSS), 0)
+  if (__builtin_expect (isgreater (fabsf (x),
+				   AS_FLOAT_CONSTANT (X_TLOSS)), 0)
       && _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_)
     /* j0(|x|>X_TLOSS) */
     return __kernel_standard_f (x, x, 134);
@@ -42,7 +43,7 @@ float
 __y0f (float x)
 {
   if (__builtin_expect (islessequal (x, 0.0f)
-                        || isgreater (x, (float) X_TLOSS), 0)
+                        || isgreater (x, AS_FLOAT_CONSTANT (X_TLOSS)), 0)
       && _LIB_VERSION != _IEEE_)
     {
       if (x < 0.0f)