aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-cppbuiltin.cc
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2022-10-03 13:10:42 +0000
committerJoseph Myers <joseph@codesourcery.com>2022-10-03 13:10:42 +0000
commit53acc10ee81116536d4eb6fbba62a90f329b75ce (patch)
treee261b4a63cbdae4122ed24463859356f5f91b89c /gcc/c-family/c-cppbuiltin.cc
parent866263a5fe0d657cb9ec06d01bbc100900159036 (diff)
downloadgcc-53acc10ee81116536d4eb6fbba62a90f329b75ce.zip
gcc-53acc10ee81116536d4eb6fbba62a90f329b75ce.tar.gz
gcc-53acc10ee81116536d4eb6fbba62a90f329b75ce.tar.bz2
c: Adjust LDBL_EPSILON for C2x for IBM long double
C2x changes the <float.h> definition of *_EPSILON to apply only to normalized numbers. The effect is that LDBL_EPSILON for IBM long double becomes 0x1p-105L instead of 0x1p-1074L. There is a reasonable case for considering this a defect fix - it originated from the issue reporting process (DR#467), though it ended up being resolved by a paper (N2326) for C2x rather than through the issue process, and code using *_EPSILON often needs to override the pre-C2x value of LDBL_EPSILON and use something on the order of magnitude of the C2x value instead. However, I've followed the conservative approach of only making the change for C2x and not for previous standard versions (and not for C++, which doesn't have the C2x changes in this area). The testcases added are intended to be valid for all long double formats. The C11 one is based on gcc.target/powerpc/rs6000-ldouble-2.c (and when we move to a C2x default, gcc.target/powerpc/rs6000-ldouble-2.c will need an appropriate option added to keep using an older language version). Tested with no regressions for cross to powerpc-linux-gnu. gcc/c-family/ * c-cppbuiltin.cc (builtin_define_float_constants): Do not special-case __*_EPSILON__ setting for IBM long double for C2x. gcc/testsuite/ * gcc.dg/c11-float-7.c, gcc.dg/c2x-float-12.c: New tests.
Diffstat (limited to 'gcc/c-family/c-cppbuiltin.cc')
-rw-r--r--gcc/c-family/c-cppbuiltin.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index d4de5a0..4b8486c 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -279,7 +279,7 @@ builtin_define_float_constants (const char *name_prefix,
/* The difference between 1 and the least value greater than 1 that is
representable in the given floating point type, b**(1-p). */
sprintf (name, "__%s_EPSILON__", name_prefix);
- if (fmt->pnan < fmt->p)
+ if (fmt->pnan < fmt->p && (c_dialect_cxx () || !flag_isoc2x))
/* This is an IBM extended double format, so 1.0 + any double is
representable precisely. */
sprintf (buf, "0x1p%d", fmt->emin - fmt->p);