public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] stdlib: Fix macro expansion producing 'defined' has undefined behavior
@ 2022-08-29 19:00 Adhemerval Zanella
  2022-08-29 20:24 ` Paul Eggert
  0 siblings, 1 reply; 2+ messages in thread
From: Adhemerval Zanella @ 2022-08-29 19:00 UTC (permalink / raw)
  To: libc-alpha

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] stdlib: Fix macro expansion producing 'defined' has undefined behavior
  2022-08-29 19:00 [PATCH] stdlib: Fix macro expansion producing 'defined' has undefined behavior Adhemerval Zanella
@ 2022-08-29 20:24 ` Paul Eggert
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2022-08-29 20:24 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

Thanks, this looks good too.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-29 20:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-29 19:00 [PATCH] stdlib: Fix macro expansion producing 'defined' has undefined behavior Adhemerval Zanella
2022-08-29 20:24 ` Paul Eggert

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