about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-03-09 15:36:53 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-08-30 08:40:47 -0300
commit6c4ee1aba17f1e71b9ec856479260de9d362fdb6 (patch)
treeb26c5e53ebc892d5b63012a8a3e851406d499b1d /stdlib
parente57d8fc97b90127de4ed3e3a9cdf663667580935 (diff)
downloadglibc-6c4ee1aba17f1e71b9ec856479260de9d362fdb6.tar.gz
glibc-6c4ee1aba17f1e71b9ec856479260de9d362fdb6.tar.xz
glibc-6c4ee1aba17f1e71b9ec856479260de9d362fdb6.zip
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.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/fpioconst.h9
1 files 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