public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] stdlib: Fix macro expansion producing 'defined' has undefined behavior
@ 2022-08-30 11:47 Adhemerval Zanella
  0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2022-08-30 11:47 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6c4ee1aba17f1e71b9ec856479260de9d362fdb6

commit 6c4ee1aba17f1e71b9ec856479260de9d362fdb6
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Mar 9 15:36:53 2022 -0300

    stdlib: Fix macro expansion producing 'defined' has undefined behavior
    
    The FPIOCONST_HAVE_EXTENDED_RANGE is defined as:
    
      #define FPIOCONST_HAVE_EXTENDED_RANGE \
        ((!defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024) \
        || __HAVE_DISTINCT_FLOAT128)
    
    Which is undefined behavior accordingly to C Standard (Preprocessing
    directives, p4).
    
    Checked on x86_64-linux-gnu.

Diff:
---
 stdlib/fpioconst.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/stdlib/fpioconst.h b/stdlib/fpioconst.h
index 1e01999941..3e185f5751 100644
--- a/stdlib/fpioconst.h
+++ b/stdlib/fpioconst.h
@@ -52,9 +52,12 @@
    - LDBL_MIN_EXP + 2)).  When _Float128 is enabled in libm and it is
    ABI-distinct from long double (e.g. on powerpc64le), we also need powers
    of 10 up to floor (log_2 (FLT128_MANT_DIG - FLT128_MIN_EXP + 2)).  */
-#define FPIOCONST_HAVE_EXTENDED_RANGE \
-  ((!defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024) \
-   || __HAVE_DISTINCT_FLOAT128)
+#if (!defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024) \
+    || __HAVE_DISTINCT_FLOAT128
+# define FPIOCONST_HAVE_EXTENDED_RANGE 1
+#else
+# define FPIOCONST_HAVE_EXTENDED_RANGE 0
+#endif
 
 #if FPIOCONST_HAVE_EXTENDED_RANGE
 # define FPIOCONST_POW10_ARRAY_SIZE	15

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-30 11:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-30 11:47 [glibc] stdlib: Fix macro expansion producing 'defined' has undefined behavior Adhemerval Zanella

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).