From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 1D3AC385B529; Thu, 12 Jan 2023 06:21:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D3AC385B529 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673504512; bh=c3vaC7yTD2fjrqKnY5lSFddYl5AXwK4h1VoS4jlMATc=; h=From:To:Subject:Date:From; b=qNVm/MaevUzGPxRQW28UzMjAoGTto6QxWVnOlDn65U0AWRzyw+CvWMMZ/GEY2oIQ0 TaefY7wbyYKP1S2q5lidEYe9grL22ZmArqGG17QAQa43q6XrJiecoxHBhWae/Pyu6A na8i5tkGmnmlmBKUEJ0+Reo0Z/DCnso6lDtqH+eg= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc/release/2.34/master] math: Properly cast X_TLOSS to float [BZ #28713] X-Act-Checkin: glibc X-Git-Author: H.J. Lu X-Git-Refname: refs/heads/release/2.34/master X-Git-Oldrev: dd0c72fb461a8879164588cd870702efae0c7237 X-Git-Newrev: 80b24b86548eee3d96130a48e760d1d6c2e0c587 Message-Id: <20230112062152.1D3AC385B529@sourceware.org> Date: Thu, 12 Jan 2023 06:21:52 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=80b24b86548eee3d96130a48e760d1d6c2e0c587 commit 80b24b86548eee3d96130a48e760d1d6c2e0c587 Author: H.J. Lu Date: Mon Dec 20 15:00:24 2021 -0800 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 (cherry picked from commit 6e30181b4a3ab6c56da0378b65f4d60504982300) Diff: --- math/math-svid-compat.h | 2 ++ math/w_j0f_compat.c | 5 +++-- math/w_j1f_compat.c | 5 +++-- math/w_jnf_compat.c | 5 +++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/math/math-svid-compat.h b/math/math-svid-compat.h index 5c18cb1b03..876cadde40 100644 --- a/math/math-svid-compat.h +++ b/math/math-svid-compat.h @@ -49,6 +49,8 @@ extern int matherr (struct exception *__exc); extern int __matherr (struct exception *__exc); #define X_TLOSS 1.41484755040568800000e+16 +#define AS_FLOAT_CONSTANT_1(x) x##f +#define AS_FLOAT_CONSTANT(x) AS_FLOAT_CONSTANT_1(x) /* Types of exceptions in the `type' field. */ #define DOMAIN 1 diff --git a/math/w_j0f_compat.c b/math/w_j0f_compat.c index a4882eadb3..f35a55219f 100644 --- a/math/w_j0f_compat.c +++ b/math/w_j0f_compat.c @@ -28,7 +28,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); @@ -43,7 +44,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) diff --git a/math/w_j1f_compat.c b/math/w_j1f_compat.c index f2ec7b327d..c5e3ccd035 100644 --- a/math/w_j1f_compat.c +++ b/math/w_j1f_compat.c @@ -28,7 +28,8 @@ float __j1f (float x) { - if (__builtin_expect (isgreater (fabsf (x), X_TLOSS), 0) + if (__builtin_expect (isgreater (fabsf (x), + AS_FLOAT_CONSTANT (X_TLOSS)), 0) && _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_) /* j1(|x|>X_TLOSS) */ return __kernel_standard_f (x, x, 136); @@ -43,7 +44,7 @@ float __y1f (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) diff --git a/math/w_jnf_compat.c b/math/w_jnf_compat.c index fb6e506009..925ccc4cd0 100644 --- a/math/w_jnf_compat.c +++ b/math/w_jnf_compat.c @@ -28,7 +28,8 @@ float __jnf (int n, 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_) /* jn(n,|x|>X_TLOSS) */ return __kernel_standard_f (n, x, 138); @@ -43,7 +44,7 @@ float __ynf (int n, 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)