about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-12-03 16:25:18 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-12-03 16:25:18 +0000
commit34e16df5a1a46e128edb9eb44a09ac5762957136 (patch)
treed8751230a2270d89531af1f7c12868dae50f534f
parentd8e2dbe3e380729a1552d546da582b02202dde0a (diff)
downloadglibc-34e16df5a1a46e128edb9eb44a09ac5762957136.tar.gz
glibc-34e16df5a1a46e128edb9eb44a09ac5762957136.tar.xz
glibc-34e16df5a1a46e128edb9eb44a09ac5762957136.zip
Fix erfc errno setting on underflow (bug 6786).
-rw-r--r--ChangeLog18
-rw-r--r--NEWS24
-rw-r--r--math/auto-libm-test-in13
-rw-r--r--math/auto-libm-test-out302
-rw-r--r--sysdeps/i386/fpu/libm-test-ulps3
-rw-r--r--sysdeps/ieee754/dbl-64/s_erf.c17
-rw-r--r--sysdeps/ieee754/flt-32/s_erff.c19
-rw-r--r--sysdeps/ieee754/ldbl-128/s_erfl.c13
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_erfl.c13
-rw-r--r--sysdeps/ieee754/ldbl-96/s_erfl.c13
-rw-r--r--sysdeps/x86_64/fpu/libm-test-ulps3
11 files changed, 410 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index cccf41943e..cf7c670ac7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2013-12-03  Joseph Myers  <joseph@codesourcery.com>
 
+	[BZ #6786]
+	* sysdeps/ieee754/dbl-64/s_erf.c: Include <errno.h> and <float.h>.
+	(__erfc): Set errno to ERANGE when returning 0 or tiny * tiny.
+	* sysdeps/ieee754/flt-32/s_erff.c: Include <errno.h> and
+	<float.h>.
+	(__erfcf): Set errno to ERANGE when returning 0 or tiny * tiny.
+	* sysdeps/ieee754/ldbl-128/s_erfl.c: Include <errno.h>.
+	(__erfcl): Set errno to ERANGE when returning 0 or tiny * tiny.
+	* sysdeps/ieee754/ldbl-128ibm/s_erfl.c: Include <errno.h>.
+	(__erfcl): Set errno to ERANGE when returning 0 or tiny * tiny.
+	* sysdeps/ieee754/ldbl-96/s_erfl.c: Include <errno.h>.
+	(__erfcl): Set errno to ERANGE when returning 0 or tiny * tiny.
+	* math/auto-libm-test-in: Don't allow missing errno from erfc.
+	Add more erfc tests.
+	* math/auto-libm-test-out: Regenerated.
+	* sysdeps/i386/fpu/libm-test-ulps: Update.
+	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
+
 	* math/auto-libm-test-in: Add tests of erf, erfc, exp, exp10,
 	exp2, expm1, j0 and j1.
 	* math/auto-libm-test-out: Regenerated.
diff --git a/NEWS b/NEWS
index f352a72f67..574cb899ce 100644
--- a/NEWS
+++ b/NEWS
@@ -9,18 +9,18 @@ Version 2.19
 
 * The following bugs are resolved with this release:
 
-  156, 387, 431, 832, 2801, 6787, 7003, 9954, 10253, 10278, 11087, 11157,
-  11214, 13028, 13982, 13985, 14029, 14032, 14143, 14155, 14547, 14699,
-  14752, 14876, 14910, 15004, 15048, 15218, 15277, 15308, 15362, 15374,
-  15400, 15427, 15483, 15522, 15531, 15532, 15601, 15608, 15609, 15610,
-  15632, 15640, 15670, 15672, 15680, 15681, 15723, 15734, 15735, 15736,
-  15748, 15749, 15754, 15760, 15763, 15764, 15797, 15799, 15825, 15844,
-  15847, 15849, 15855, 15856, 15857, 15859, 15867, 15886, 15887, 15890,
-  15892, 15893, 15895, 15897, 15905, 15909, 15917, 15919, 15921, 15923,
-  15939, 15948, 15963, 15966, 15985, 15988, 15997, 16032, 16034, 16036,
-  16037, 16041, 16055, 16071, 16072, 16074, 16077, 16078, 16103, 16112,
-  16143, 16144, 16146, 16150, 16151, 16153, 16167, 16172, 16195, 16214,
-  16245, 16271, 16289.
+  156, 387, 431, 832, 2801, 6786, 6787, 7003, 9954, 10253, 10278, 11087,
+  11157, 11214, 13028, 13982, 13985, 14029, 14032, 14143, 14155, 14547,
+  14699, 14752, 14876, 14910, 15004, 15048, 15218, 15277, 15308, 15362,
+  15374, 15400, 15427, 15483, 15522, 15531, 15532, 15601, 15608, 15609,
+  15610, 15632, 15640, 15670, 15672, 15680, 15681, 15723, 15734, 15735,
+  15736, 15748, 15749, 15754, 15760, 15763, 15764, 15797, 15799, 15825,
+  15844, 15847, 15849, 15855, 15856, 15857, 15859, 15867, 15886, 15887,
+  15890, 15892, 15893, 15895, 15897, 15905, 15909, 15917, 15919, 15921,
+  15923, 15939, 15948, 15963, 15966, 15985, 15988, 15997, 16032, 16034,
+  16036, 16037, 16041, 16055, 16071, 16072, 16074, 16077, 16078, 16103,
+  16112, 16143, 16144, 16146, 16150, 16151, 16153, 16167, 16172, 16195,
+  16214, 16245, 16271, 16289.
 
 * The public headers no longer use __unused nor __block.  This change is to
   support compiling programs that are derived from BSD sources and use
diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index 392cc57bf3..126a9eaec7 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -149,9 +149,18 @@ erfc 4.125
 erfc 0x1.ffa002p+2
 erfc 0x1.ffffc8p+2
 erfc -0x1.fffffffffffff8p-2
-# Bug 6786: errno may not be set on underflow.
-erfc 27.0 missing-errno
+erfc 26.0
+erfc 27.0
+erfc 28.0
 erfc 0x1.ffff56789abcdef0123456789a8p+2
+erfc 100
+erfc 106
+erfc 106.5
+erfc 106.625
+erfc 107
+erfc 108
+erfc 1000
+erfc max
 
 exp 0
 exp -0
diff --git a/math/auto-libm-test-out b/math/auto-libm-test-out
index 8769a9df7c..9b3c398893 100644
--- a/math/auto-libm-test-out
+++ b/math/auto-libm-test-out
@@ -5176,10 +5176,35 @@ erfc -0x1.fffffffffffff8p-2
 = erfc tonearest ldbl-128ibm -0x7.ffffffffffffep-4L : 0x1.853f7ae0c76e8f9c90d4d08ca18p+0L : inexact-ok
 = erfc towardzero ldbl-128ibm -0x7.ffffffffffffep-4L : 0x1.853f7ae0c76e8f9c90d4d08ca1p+0L : inexact-ok
 = erfc upward ldbl-128ibm -0x7.ffffffffffffep-4L : 0x1.853f7ae0c76e8f9c90d4d08ca18p+0L : inexact-ok
-erfc 27.0 missing-errno
-= erfc downward flt-32 0x1.bp+4f : 0x0p+0f : inexact-ok underflow errno-erange errno-erange-ok
-= erfc tonearest flt-32 0x1.bp+4f : 0x0p+0f : inexact-ok underflow errno-erange errno-erange-ok
-= erfc towardzero flt-32 0x1.bp+4f : 0x0p+0f : inexact-ok underflow errno-erange errno-erange-ok
+erfc 26.0
+= erfc downward flt-32 0x1.ap+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc tonearest flt-32 0x1.ap+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc towardzero flt-32 0x1.ap+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc upward flt-32 0x1.ap+4f : 0x8p-152f : inexact-ok underflow errno-erange-ok
+= erfc downward dbl-64 0x1.ap+4 : 0x9.425ff0e6f5118p-984 : inexact-ok
+= erfc tonearest dbl-64 0x1.ap+4 : 0x9.425ff0e6f512p-984 : inexact-ok
+= erfc towardzero dbl-64 0x1.ap+4 : 0x9.425ff0e6f5118p-984 : inexact-ok
+= erfc upward dbl-64 0x1.ap+4 : 0x9.425ff0e6f512p-984 : inexact-ok
+= erfc downward ldbl-96-intel 0x1.ap+4L : 0x9.425ff0e6f511d74p-984L : inexact-ok
+= erfc tonearest ldbl-96-intel 0x1.ap+4L : 0x9.425ff0e6f511d75p-984L : inexact-ok
+= erfc towardzero ldbl-96-intel 0x1.ap+4L : 0x9.425ff0e6f511d74p-984L : inexact-ok
+= erfc upward ldbl-96-intel 0x1.ap+4L : 0x9.425ff0e6f511d75p-984L : inexact-ok
+= erfc downward ldbl-96-m68k 0x1.ap+4L : 0x9.425ff0e6f511d74p-984L : inexact-ok
+= erfc tonearest ldbl-96-m68k 0x1.ap+4L : 0x9.425ff0e6f511d75p-984L : inexact-ok
+= erfc towardzero ldbl-96-m68k 0x1.ap+4L : 0x9.425ff0e6f511d74p-984L : inexact-ok
+= erfc upward ldbl-96-m68k 0x1.ap+4L : 0x9.425ff0e6f511d75p-984L : inexact-ok
+= erfc downward ldbl-128 0x1.ap+4L : 0x9.425ff0e6f511d74db40cfbbceffp-984L : inexact-ok
+= erfc tonearest ldbl-128 0x1.ap+4L : 0x9.425ff0e6f511d74db40cfbbceffp-984L : inexact-ok
+= erfc towardzero ldbl-128 0x1.ap+4L : 0x9.425ff0e6f511d74db40cfbbceffp-984L : inexact-ok
+= erfc upward ldbl-128 0x1.ap+4L : 0x9.425ff0e6f511d74db40cfbbceff8p-984L : inexact-ok
+= erfc downward ldbl-128ibm 0x1.ap+4L : 0x9.425ff0e6f511d74db40cfb8p-984L : inexact-ok underflow errno-erange-ok
+= erfc tonearest ldbl-128ibm 0x1.ap+4L : 0x9.425ff0e6f511d74db40cfbcp-984L : inexact-ok underflow errno-erange-ok
+= erfc towardzero ldbl-128ibm 0x1.ap+4L : 0x9.425ff0e6f511d74db40cfb8p-984L : inexact-ok underflow errno-erange-ok
+= erfc upward ldbl-128ibm 0x1.ap+4L : 0x9.425ff0e6f511d74db40cfbcp-984L : inexact-ok underflow errno-erange-ok
+erfc 27.0
+= erfc downward flt-32 0x1.bp+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc tonearest flt-32 0x1.bp+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc towardzero flt-32 0x1.bp+4f : 0x0p+0f : inexact-ok underflow errno-erange
 = erfc upward flt-32 0x1.bp+4f : 0x8p-152f : inexact-ok underflow errno-erange-ok
 = erfc downward dbl-64 0x1.bp+4 : 0x6.783cp-1060 : inexact-ok underflow errno-erange-ok
 = erfc tonearest dbl-64 0x1.bp+4 : 0x6.783cp-1060 : inexact-ok underflow errno-erange-ok
@@ -5201,6 +5226,31 @@ erfc 27.0 missing-errno
 = erfc tonearest ldbl-128ibm 0x1.bp+4L : 0x6.783cp-1060L : inexact-ok underflow errno-erange-ok
 = erfc towardzero ldbl-128ibm 0x1.bp+4L : 0x6.783cp-1060L : inexact-ok underflow errno-erange-ok
 = erfc upward ldbl-128ibm 0x1.bp+4L : 0x6.784p-1060L : inexact-ok underflow errno-erange-ok
+erfc 28.0
+= erfc downward flt-32 0x1.cp+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc tonearest flt-32 0x1.cp+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc towardzero flt-32 0x1.cp+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc upward flt-32 0x1.cp+4f : 0x8p-152f : inexact-ok underflow errno-erange-ok
+= erfc downward dbl-64 0x1.cp+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc tonearest dbl-64 0x1.cp+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc towardzero dbl-64 0x1.cp+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc upward dbl-64 0x1.cp+4 : 0x4p-1076 : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-intel 0x1.cp+4L : 0x9.cd4b80875a8ec66p-1140L : inexact-ok
+= erfc tonearest ldbl-96-intel 0x1.cp+4L : 0x9.cd4b80875a8ec66p-1140L : inexact-ok
+= erfc towardzero ldbl-96-intel 0x1.cp+4L : 0x9.cd4b80875a8ec66p-1140L : inexact-ok
+= erfc upward ldbl-96-intel 0x1.cp+4L : 0x9.cd4b80875a8ec67p-1140L : inexact-ok
+= erfc downward ldbl-96-m68k 0x1.cp+4L : 0x9.cd4b80875a8ec66p-1140L : inexact-ok
+= erfc tonearest ldbl-96-m68k 0x1.cp+4L : 0x9.cd4b80875a8ec66p-1140L : inexact-ok
+= erfc towardzero ldbl-96-m68k 0x1.cp+4L : 0x9.cd4b80875a8ec66p-1140L : inexact-ok
+= erfc upward ldbl-96-m68k 0x1.cp+4L : 0x9.cd4b80875a8ec67p-1140L : inexact-ok
+= erfc downward ldbl-128 0x1.cp+4L : 0x9.cd4b80875a8ec6603b9a1f1beadp-1140L : inexact-ok
+= erfc tonearest ldbl-128 0x1.cp+4L : 0x9.cd4b80875a8ec6603b9a1f1bead8p-1140L : inexact-ok
+= erfc towardzero ldbl-128 0x1.cp+4L : 0x9.cd4b80875a8ec6603b9a1f1beadp-1140L : inexact-ok
+= erfc upward ldbl-128 0x1.cp+4L : 0x9.cd4b80875a8ec6603b9a1f1bead8p-1140L : inexact-ok
+= erfc downward ldbl-128ibm 0x1.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128ibm 0x1.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128ibm 0x1.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128ibm 0x1.cp+4L : 0x4p-1076L : inexact-ok underflow errno-erange-ok
 erfc 0x1.ffff56789abcdef0123456789a8p+2
 = erfc downward flt-32 0x7.fffd6p+0f : 0xe.3cd88p-100f : inexact-ok
 = erfc tonearest flt-32 0x7.fffd6p+0f : 0xe.3cd88p-100f : inexact-ok
@@ -5330,6 +5380,250 @@ erfc 0x1.ffff56789abcdef0123456789a8p+2
 = erfc tonearest ldbl-128ibm 0x7.fffd59e26af37bc048d159e26ap+0L : 0xe.3cddffbbe84faf818649c2377p-100L : inexact-ok
 = erfc towardzero ldbl-128ibm 0x7.fffd59e26af37bc048d159e26ap+0L : 0xe.3cddffbbe84faf818649c2377p-100L : inexact-ok
 = erfc upward ldbl-128ibm 0x7.fffd59e26af37bc048d159e26ap+0L : 0xe.3cddffbbe84faf818649c23774p-100L : inexact-ok
+erfc 100
+= erfc downward flt-32 0x6.4p+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc tonearest flt-32 0x6.4p+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc towardzero flt-32 0x6.4p+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc upward flt-32 0x6.4p+4f : 0x8p-152f : inexact-ok underflow errno-erange-ok
+= erfc downward dbl-64 0x6.4p+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc tonearest dbl-64 0x6.4p+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc towardzero dbl-64 0x6.4p+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc upward dbl-64 0x6.4p+4 : 0x4p-1076 : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-intel 0x6.4p+4L : 0x2.fd514cef7750e588p-14436L : inexact-ok
+= erfc tonearest ldbl-96-intel 0x6.4p+4L : 0x2.fd514cef7750e588p-14436L : inexact-ok
+= erfc towardzero ldbl-96-intel 0x6.4p+4L : 0x2.fd514cef7750e588p-14436L : inexact-ok
+= erfc upward ldbl-96-intel 0x6.4p+4L : 0x2.fd514cef7750e58cp-14436L : inexact-ok
+= erfc downward ldbl-96-m68k 0x6.4p+4L : 0x2.fd514cef7750e588p-14436L : inexact-ok
+= erfc tonearest ldbl-96-m68k 0x6.4p+4L : 0x2.fd514cef7750e588p-14436L : inexact-ok
+= erfc towardzero ldbl-96-m68k 0x6.4p+4L : 0x2.fd514cef7750e588p-14436L : inexact-ok
+= erfc upward ldbl-96-m68k 0x6.4p+4L : 0x2.fd514cef7750e58cp-14436L : inexact-ok
+= erfc downward ldbl-128 0x6.4p+4L : 0x2.fd514cef7750e58906601ff35dcp-14436L : inexact-ok
+= erfc tonearest ldbl-128 0x6.4p+4L : 0x2.fd514cef7750e58906601ff35dcp-14436L : inexact-ok
+= erfc towardzero ldbl-128 0x6.4p+4L : 0x2.fd514cef7750e58906601ff35dcp-14436L : inexact-ok
+= erfc upward ldbl-128 0x6.4p+4L : 0x2.fd514cef7750e58906601ff35dc2p-14436L : inexact-ok
+= erfc downward ldbl-128ibm 0x6.4p+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128ibm 0x6.4p+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128ibm 0x6.4p+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128ibm 0x6.4p+4L : 0x4p-1076L : inexact-ok underflow errno-erange-ok
+erfc 106
+= erfc downward flt-32 0x6.ap+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc tonearest flt-32 0x6.ap+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc towardzero flt-32 0x6.ap+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc upward flt-32 0x6.ap+4f : 0x8p-152f : inexact-ok underflow errno-erange-ok
+= erfc downward dbl-64 0x6.ap+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc tonearest dbl-64 0x6.ap+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc towardzero dbl-64 0x6.ap+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc upward dbl-64 0x6.ap+4 : 0x4p-1076 : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-intel 0x6.ap+4L : 0x5.028a2f1656a432dp-16220L : inexact-ok
+= erfc tonearest ldbl-96-intel 0x6.ap+4L : 0x5.028a2f1656a432d8p-16220L : inexact-ok
+= erfc towardzero ldbl-96-intel 0x6.ap+4L : 0x5.028a2f1656a432dp-16220L : inexact-ok
+= erfc upward ldbl-96-intel 0x6.ap+4L : 0x5.028a2f1656a432d8p-16220L : inexact-ok
+= erfc downward ldbl-96-m68k 0x6.ap+4L : 0x5.028a2f1656a432dp-16220L : inexact-ok
+= erfc tonearest ldbl-96-m68k 0x6.ap+4L : 0x5.028a2f1656a432d8p-16220L : inexact-ok
+= erfc towardzero ldbl-96-m68k 0x6.ap+4L : 0x5.028a2f1656a432dp-16220L : inexact-ok
+= erfc upward ldbl-96-m68k 0x6.ap+4L : 0x5.028a2f1656a432d8p-16220L : inexact-ok
+= erfc downward ldbl-128 0x6.ap+4L : 0x5.028a2f1656a432d79f76a6f2df48p-16220L : inexact-ok
+= erfc tonearest ldbl-128 0x6.ap+4L : 0x5.028a2f1656a432d79f76a6f2df48p-16220L : inexact-ok
+= erfc towardzero ldbl-128 0x6.ap+4L : 0x5.028a2f1656a432d79f76a6f2df48p-16220L : inexact-ok
+= erfc upward ldbl-128 0x6.ap+4L : 0x5.028a2f1656a432d79f76a6f2df4cp-16220L : inexact-ok
+= erfc downward ldbl-128ibm 0x6.ap+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128ibm 0x6.ap+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128ibm 0x6.ap+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128ibm 0x6.ap+4L : 0x4p-1076L : inexact-ok underflow errno-erange-ok
+erfc 106.5
+= erfc downward flt-32 0x6.a8p+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc tonearest flt-32 0x6.a8p+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc towardzero flt-32 0x6.a8p+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc upward flt-32 0x6.a8p+4f : 0x8p-152f : inexact-ok underflow errno-erange-ok
+= erfc downward dbl-64 0x6.a8p+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc tonearest dbl-64 0x6.a8p+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc towardzero dbl-64 0x6.a8p+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc upward dbl-64 0x6.a8p+4 : 0x4p-1076 : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-intel 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a4p-16372L : inexact-ok
+= erfc tonearest ldbl-96-intel 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a4p-16372L : inexact-ok
+= erfc towardzero ldbl-96-intel 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a4p-16372L : inexact-ok
+= erfc upward ldbl-96-intel 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a8p-16372L : inexact-ok
+= erfc downward ldbl-96-m68k 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a4p-16372L : inexact-ok
+= erfc tonearest ldbl-96-m68k 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a4p-16372L : inexact-ok
+= erfc towardzero ldbl-96-m68k 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a4p-16372L : inexact-ok
+= erfc upward ldbl-96-m68k 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a8p-16372L : inexact-ok
+= erfc downward ldbl-128 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a5e595291fc8c4p-16372L : inexact-ok
+= erfc tonearest ldbl-128 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a5e595291fc8c4p-16372L : inexact-ok
+= erfc towardzero ldbl-128 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a5e595291fc8c4p-16372L : inexact-ok
+= erfc upward ldbl-128 0x6.a8p+4L : 0x2.0b5b5b3bbf7d96a5e595291fc8c6p-16372L : inexact-ok
+= erfc downward ldbl-128ibm 0x6.a8p+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128ibm 0x6.a8p+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128ibm 0x6.a8p+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128ibm 0x6.a8p+4L : 0x4p-1076L : inexact-ok underflow errno-erange-ok
+erfc 106.625
+= erfc downward flt-32 0x6.aap+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc tonearest flt-32 0x6.aap+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc towardzero flt-32 0x6.aap+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc upward flt-32 0x6.aap+4f : 0x8p-152f : inexact-ok underflow errno-erange-ok
+= erfc downward dbl-64 0x6.aap+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc tonearest dbl-64 0x6.aap+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc towardzero dbl-64 0x6.aap+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc upward dbl-64 0x6.aap+4 : 0x4p-1076 : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-intel 0x6.aap+4L : 0x6.0b6ee9978p-16412L : inexact-ok underflow errno-erange-ok
+= erfc tonearest ldbl-96-intel 0x6.aap+4L : 0x6.0b6ee998p-16412L : inexact-ok underflow errno-erange-ok
+= erfc towardzero ldbl-96-intel 0x6.aap+4L : 0x6.0b6ee9978p-16412L : inexact-ok underflow errno-erange-ok
+= erfc upward ldbl-96-intel 0x6.aap+4L : 0x6.0b6ee998p-16412L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-m68k 0x6.aap+4L : 0x6.0b6ee997cp-16412L : inexact-ok underflow errno-erange-ok
+= erfc tonearest ldbl-96-m68k 0x6.aap+4L : 0x6.0b6ee997cp-16412L : inexact-ok underflow errno-erange-ok
+= erfc towardzero ldbl-96-m68k 0x6.aap+4L : 0x6.0b6ee997cp-16412L : inexact-ok underflow errno-erange-ok
+= erfc upward ldbl-96-m68k 0x6.aap+4L : 0x6.0b6ee998p-16412L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128 0x6.aap+4L : 0x6.0b6ee997d3343b5bf2f08p-16412L : inexact-ok underflow errno-erange-ok
+= erfc tonearest ldbl-128 0x6.aap+4L : 0x6.0b6ee997d3343b5bf2f08p-16412L : inexact-ok underflow errno-erange-ok
+= erfc towardzero ldbl-128 0x6.aap+4L : 0x6.0b6ee997d3343b5bf2f08p-16412L : inexact-ok underflow errno-erange-ok
+= erfc upward ldbl-128 0x6.aap+4L : 0x6.0b6ee997d3343b5bf2f0cp-16412L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128ibm 0x6.aap+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128ibm 0x6.aap+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128ibm 0x6.aap+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128ibm 0x6.aap+4L : 0x4p-1076L : inexact-ok underflow errno-erange-ok
+erfc 107
+= erfc downward flt-32 0x6.bp+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc tonearest flt-32 0x6.bp+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc towardzero flt-32 0x6.bp+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc upward flt-32 0x6.bp+4f : 0x8p-152f : inexact-ok underflow errno-erange-ok
+= erfc downward dbl-64 0x6.bp+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc tonearest dbl-64 0x6.bp+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc towardzero dbl-64 0x6.bp+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc upward dbl-64 0x6.bp+4 : 0x4p-1076 : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-intel 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-intel 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-intel 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-intel 0x6.bp+4L : 0x8p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-m68k 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-m68k 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-m68k 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-m68k 0x6.bp+4L : 0x4p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128 0x6.bp+4L : 0x4p-16496L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128ibm 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128ibm 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128ibm 0x6.bp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128ibm 0x6.bp+4L : 0x4p-1076L : inexact-ok underflow errno-erange-ok
+erfc 108
+= erfc downward flt-32 0x6.cp+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc tonearest flt-32 0x6.cp+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc towardzero flt-32 0x6.cp+4f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc upward flt-32 0x6.cp+4f : 0x8p-152f : inexact-ok underflow errno-erange-ok
+= erfc downward dbl-64 0x6.cp+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc tonearest dbl-64 0x6.cp+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc towardzero dbl-64 0x6.cp+4 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc upward dbl-64 0x6.cp+4 : 0x4p-1076 : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-intel 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-intel 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-intel 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-intel 0x6.cp+4L : 0x8p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-m68k 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-m68k 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-m68k 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-m68k 0x6.cp+4L : 0x4p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128 0x6.cp+4L : 0x4p-16496L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128ibm 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128ibm 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128ibm 0x6.cp+4L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128ibm 0x6.cp+4L : 0x4p-1076L : inexact-ok underflow errno-erange-ok
+erfc 1000
+= erfc downward flt-32 0x3.e8p+8f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc tonearest flt-32 0x3.e8p+8f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc towardzero flt-32 0x3.e8p+8f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc upward flt-32 0x3.e8p+8f : 0x8p-152f : inexact-ok underflow errno-erange-ok
+= erfc downward dbl-64 0x3.e8p+8 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc tonearest dbl-64 0x3.e8p+8 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc towardzero dbl-64 0x3.e8p+8 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc upward dbl-64 0x3.e8p+8 : 0x4p-1076 : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-intel 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-intel 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-intel 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-intel 0x3.e8p+8L : 0x8p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-m68k 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-m68k 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-m68k 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-m68k 0x3.e8p+8L : 0x4p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128 0x3.e8p+8L : 0x4p-16496L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128ibm 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128ibm 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128ibm 0x3.e8p+8L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128ibm 0x3.e8p+8L : 0x4p-1076L : inexact-ok underflow errno-erange-ok
+erfc max
+= erfc downward flt-32 0xf.fffffp+124f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc tonearest flt-32 0xf.fffffp+124f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc towardzero flt-32 0xf.fffffp+124f : 0x0p+0f : inexact-ok underflow errno-erange
+= erfc upward flt-32 0xf.fffffp+124f : 0x8p-152f : inexact-ok underflow errno-erange-ok
+= erfc downward dbl-64 0xf.fffffp+124 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc tonearest dbl-64 0xf.fffffp+124 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc towardzero dbl-64 0xf.fffffp+124 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc upward dbl-64 0xf.fffffp+124 : 0x4p-1076 : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-intel 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-intel 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-intel 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-intel 0xf.fffffp+124L : 0x8p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-m68k 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-m68k 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-m68k 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-m68k 0xf.fffffp+124L : 0x4p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128 0xf.fffffp+124L : 0x4p-16496L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128ibm 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128ibm 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128ibm 0xf.fffffp+124L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128ibm 0xf.fffffp+124L : 0x4p-1076L : inexact-ok underflow errno-erange-ok
+= erfc downward dbl-64 0xf.ffffffffffff8p+1020 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc tonearest dbl-64 0xf.ffffffffffff8p+1020 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc towardzero dbl-64 0xf.ffffffffffff8p+1020 : 0x0p+0 : inexact-ok underflow errno-erange
+= erfc upward dbl-64 0xf.ffffffffffff8p+1020 : 0x4p-1076 : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-intel 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-intel 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-intel 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-intel 0xf.ffffffffffff8p+1020L : 0x8p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-m68k 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-m68k 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-m68k 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-m68k 0xf.ffffffffffff8p+1020L : 0x4p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128 0xf.ffffffffffff8p+1020L : 0x4p-16496L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128ibm 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128ibm 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128ibm 0xf.ffffffffffff8p+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128ibm 0xf.ffffffffffff8p+1020L : 0x4p-1076L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-intel 0xf.fffffffffffffffp+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-intel 0xf.fffffffffffffffp+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-intel 0xf.fffffffffffffffp+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-intel 0xf.fffffffffffffffp+16380L : 0x8p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-96-m68k 0xf.fffffffffffffffp+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-96-m68k 0xf.fffffffffffffffp+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-96-m68k 0xf.fffffffffffffffp+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-96-m68k 0xf.fffffffffffffffp+16380L : 0x4p-16448L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128 0xf.fffffffffffffffp+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128 0xf.fffffffffffffffp+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128 0xf.fffffffffffffffp+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128 0xf.fffffffffffffffp+16380L : 0x4p-16496L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128 0xf.fffffffffffffffffffffffffff8p+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128 0xf.fffffffffffffffffffffffffff8p+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128 0xf.fffffffffffffffffffffffffff8p+16380L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128 0xf.fffffffffffffffffffffffffff8p+16380L : 0x4p-16496L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128 0xf.ffffffffffffbffffffffffffcp+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128 0xf.ffffffffffffbffffffffffffcp+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128 0xf.ffffffffffffbffffffffffffcp+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128 0xf.ffffffffffffbffffffffffffcp+1020L : 0x4p-16496L : inexact-ok underflow errno-erange-ok
+= erfc downward ldbl-128ibm 0xf.ffffffffffffbffffffffffffcp+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc tonearest ldbl-128ibm 0xf.ffffffffffffbffffffffffffcp+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc towardzero ldbl-128ibm 0xf.ffffffffffffbffffffffffffcp+1020L : 0x0p+0L : inexact-ok underflow errno-erange
+= erfc upward ldbl-128ibm 0xf.ffffffffffffbffffffffffffcp+1020L : 0x4p-1076L : inexact-ok underflow errno-erange-ok
 exp 0
 = exp downward flt-32 0x0p+0f : 0x1p+0f : inexact-ok
 = exp tonearest flt-32 0x0p+0f : 0x1p+0f : inexact-ok
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index 0234a61b68..a492da30d6 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -5946,6 +5946,9 @@ double: 1
 idouble: 1
 ildouble: 1
 ldouble: 1
+Test "erfc (0x6.4p+4)":
+ildouble: 1
+ldouble: 1
 Test "erfc (0x7.fe8008p+0)":
 ildouble: 1
 ldouble: 1
diff --git a/sysdeps/ieee754/dbl-64/s_erf.c b/sysdeps/ieee754/dbl-64/s_erf.c
index aab4ed593e..3f37397224 100644
--- a/sysdeps/ieee754/dbl-64/s_erf.c
+++ b/sysdeps/ieee754/dbl-64/s_erf.c
@@ -112,6 +112,8 @@ static char rcsid[] = "$NetBSD: s_erf.c,v 1.8 1995/05/10 20:47:05 jtc Exp $";
  */
 
 
+#include <errno.h>
+#include <float.h>
 #include <math.h>
 #include <math_private.h>
 
@@ -391,14 +393,25 @@ __erfc (double x)
       r = __ieee754_exp (-z * z - 0.5625) *
 	  __ieee754_exp ((z - x) * (z + x) + R / S);
       if (hx > 0)
-	return r / x;
+	{
+#if FLT_EVAL_METHOD != 0
+	  volatile
+#endif
+	  double ret = r / x;
+	  if (ret == 0)
+	    __set_errno (ERANGE);
+	  return ret;
+	}
       else
 	return two - r / x;
     }
   else
     {
       if (hx > 0)
-	return tiny * tiny;
+	{
+	  __set_errno (ERANGE);
+	  return tiny * tiny;
+	}
       else
 	return two - tiny;
     }
diff --git a/sysdeps/ieee754/flt-32/s_erff.c b/sysdeps/ieee754/flt-32/s_erff.c
index 7d17f426e9..7c09589648 100644
--- a/sysdeps/ieee754/flt-32/s_erff.c
+++ b/sysdeps/ieee754/flt-32/s_erff.c
@@ -17,6 +17,8 @@
 static char rcsid[] = "$NetBSD: s_erff.c,v 1.4 1995/05/10 20:47:07 jtc Exp $";
 #endif
 
+#include <errno.h>
+#include <float.h>
 #include <math.h>
 #include <math_private.h>
 
@@ -203,9 +205,22 @@ float __erfcf(float x)
 	    SET_FLOAT_WORD(z,ix&0xffffe000);
 	    r  =  __ieee754_expf(-z*z-(float)0.5625)*
 			__ieee754_expf((z-x)*(z+x)+R/S);
-	    if(hx>0) return r/x; else return two-r/x;
+	    if(hx>0) {
+#if FLT_EVAL_METHOD != 0
+		volatile
+#endif
+		float ret = r/x;
+		if (ret == 0)
+		    __set_errno (ERANGE);
+		return ret;
+	    } else
+		return two-r/x;
 	} else {
-	    if(hx>0) return tiny*tiny; else return two-tiny;
+	    if(hx>0) {
+		__set_errno (ERANGE);
+		return tiny*tiny;
+	    } else
+		return two-tiny;
 	}
 }
 weak_alias (__erfcf, erfcf)
diff --git a/sysdeps/ieee754/ldbl-128/s_erfl.c b/sysdeps/ieee754/ldbl-128/s_erfl.c
index d9d4195ad2..ef65ed8922 100644
--- a/sysdeps/ieee754/ldbl-128/s_erfl.c
+++ b/sysdeps/ieee754/ldbl-128/s_erfl.c
@@ -96,6 +96,7 @@
  *		erfc/erf(NaN) is NaN
  */
 
+#include <errno.h>
 #include <math.h>
 #include <math_private.h>
 
@@ -918,14 +919,22 @@ __erfcl (long double x)
       r = __ieee754_expl (-z * z - 0.5625) *
 	__ieee754_expl ((z - x) * (z + x) + p);
       if ((sign & 0x80000000) == 0)
-	return r / x;
+	{
+	  long double ret = r / x;
+	  if (ret == 0)
+	    __set_errno (ERANGE);
+	  return ret;
+	}
       else
 	return two - r / x;
     }
   else
     {
       if ((sign & 0x80000000) == 0)
-	return tiny * tiny;
+	{
+	  __set_errno (ERANGE);
+	  return tiny * tiny;
+	}
       else
 	return two - tiny;
     }
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_erfl.c b/sysdeps/ieee754/ldbl-128ibm/s_erfl.c
index c861c65ccf..95dc415845 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_erfl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_erfl.c
@@ -101,6 +101,7 @@
  *		erfc/erf(NaN) is NaN
  */
 
+#include <errno.h>
 #include <math.h>
 #include <math_private.h>
 #include <math_ldbl_opt.h>
@@ -940,14 +941,22 @@ __erfcl (long double x)
       r = __ieee754_expl (-z * z - 0.5625) *
 	__ieee754_expl ((z - x) * (z + x) + p);
       if ((hx & 0x80000000) == 0)
-	return r / x;
+	{
+	  long double ret = r / x;
+	  if (ret == 0)
+	    __set_errno (ERANGE);
+	  return ret;
+	}
       else
 	return two - r / x;
     }
   else
     {
       if ((hx & 0x80000000) == 0)
-	return tiny * tiny;
+	{
+	  __set_errno (ERANGE);
+	  return tiny * tiny;
+	}
       else
 	return two - tiny;
     }
diff --git a/sysdeps/ieee754/ldbl-96/s_erfl.c b/sysdeps/ieee754/ldbl-96/s_erfl.c
index 17d2278524..47e4b9e909 100644
--- a/sysdeps/ieee754/ldbl-96/s_erfl.c
+++ b/sysdeps/ieee754/ldbl-96/s_erfl.c
@@ -104,6 +104,7 @@
  */
 
 
+#include <errno.h>
 #include <math.h>
 #include <math_private.h>
 
@@ -422,14 +423,22 @@ __erfcl (long double x)
       r = __ieee754_expl (-z * z - 0.5625) *
 	__ieee754_expl ((z - x) * (z + x) + R / S);
       if ((se & 0x8000) == 0)
-	return r / x;
+	{
+	  long double ret = r / x;
+	  if (ret == 0)
+	    __set_errno (ERANGE);
+	  return ret;
+	}
       else
 	return two - r / x;
     }
   else
     {
       if ((se & 0x8000) == 0)
-	return tiny * tiny;
+	{
+	  __set_errno (ERANGE);
+	  return tiny * tiny;
+	}
       else
 	return two - tiny;
     }
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index 209fd49b69..5c923e69b3 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -6776,6 +6776,9 @@ double: 1
 idouble: 1
 ildouble: 1
 ldouble: 1
+Test "erfc (0x6.4p+4)":
+ildouble: 1
+ldouble: 1
 Test "erfc (0x7.fe8008p+0)":
 float: 1
 ifloat: 1