public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/azanella/clang] math: Suppress clang warning on math_check_force_underflow
Date: Fri, 28 Oct 2022 17:40:44 +0000 (GMT)	[thread overview]
Message-ID: <20221028174044.5F6153889E3A@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4685f533a2c76640ca6e96f0b3c60fea1ad94efc

commit 4685f533a2c76640ca6e96f0b3c60fea1ad94efc
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 10 13:53:13 2022 -0300

    math: Suppress clang warning on math_check_force_underflow
    
    Clang warns:
    
      ../sysdeps/x86/fpu/powl_helper.c:233:3: error: absolute value function
      '__builtin_fabsf' given an argument of type 'typeof (res)' (aka 'long
      double') but has parameter of type 'float' which may cause truncation of
      value [-Werror,-Wabsolute-value]
        math_check_force_underflow (res);
        ^
      ./math-underflow.h:45:11: note: expanded from macro
      'math_check_force_underflow'
            if (fabs_tg (force_underflow_tmp)                         \
                ^
      ./math-underflow.h:27:20: note: expanded from macro 'fabs_tg'
      #define fabs_tg(x) __MATH_TG ((x), (__typeof (x)) __builtin_fabs, (x))
                         ^
      ../math/math.h:899:16: note: expanded from macro '__MATH_TG'
                     float: FUNC ## f ARGS,           \
                            ^
      <scratch space>:73:1: note: expanded from here
      __builtin_fabsf
      ^

Diff:
---
 math/math-underflow.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/math/math-underflow.h b/math/math-underflow.h
index c9d363ddd1..4bec3d349e 100644
--- a/math/math-underflow.h
+++ b/math/math-underflow.h
@@ -23,6 +23,7 @@
 #include <math.h>
 
 #include <math-barriers.h>
+#include <libc-diag.h>
 
 #define fabs_tg(x) __MATH_TG ((x), (__typeof (x)) __builtin_fabs, (x))
 
@@ -37,10 +38,15 @@
 #define min_of_type(x) __MATH_TG ((x), (__typeof (x)) min_of_type_, ())
 
 /* If X (which is not a NaN) is subnormal, force an underflow
-   exception.  */
+   exception.
+
+   clang issues a warning where _Generic is using a non expected
+   builtin which may cause truncation of value.  */
 #define math_check_force_underflow(x)				\
   do								\
     {								\
+      DIAG_PUSH_NEEDS_COMMENT_CLANG;				\
+      DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wabsolute-value"); \
       __typeof (x) force_underflow_tmp = (x);			\
       if (fabs_tg (force_underflow_tmp)				\
 	  < min_of_type (force_underflow_tmp))			\
@@ -49,6 +55,7 @@
 	    = force_underflow_tmp * force_underflow_tmp;	\
 	  math_force_eval (force_underflow_tmp2);		\
 	}							\
+      DIAG_POP_NEEDS_COMMENT_CLANG;				\
     }								\
   while (0)
 /* Likewise, but X is also known to be nonnegative.  */

             reply	other threads:[~2022-10-28 17:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28 17:40 Adhemerval Zanella [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-02-09 17:30 Adhemerval Zanella
2024-02-07 14:05 Adhemerval Zanella
2024-01-29 17:56 Adhemerval Zanella
2023-12-21 18:52 Adhemerval Zanella
2023-09-28 17:50 Adhemerval Zanella
2023-08-30 12:35 Adhemerval Zanella
2023-02-09 19:47 Adhemerval Zanella
2022-10-04 12:58 Adhemerval Zanella
2022-06-09 21:19 Adhemerval Zanella
2022-06-09 13:15 Adhemerval Zanella
2022-06-03 14:05 Adhemerval Zanella
2022-05-13 14:19 Adhemerval Zanella
2022-05-12 19:32 Adhemerval Zanella
2022-05-10 18:23 Adhemerval Zanella
2022-04-29 14:03 Adhemerval Zanella
2022-04-04 12:53 Adhemerval Zanella
2022-03-31 19:05 Adhemerval Zanella
2022-03-29 20:28 Adhemerval Zanella
2022-03-16 18:02 Adhemerval Zanella
2022-03-15 18:40 Adhemerval Zanella
2022-03-11 17:24 Adhemerval Zanella
2022-03-10 19:23 Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221028174044.5F6153889E3A@sourceware.org \
    --to=azanella@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).