Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix ctan, ctanh missing underflows (bug 18595).
Similar to various other bugs in this area, ctan and ctanh can fail to
raise the underflow exception for some cases of results that are tiny
and inexact.  This patch forces the exception in a similar way to
previous fixes.

Tested for x86_64 and x86.

	[BZ #18595]
	* math/s_ctan.c (__ctan): Force underflow exception for results
	whose real or imaginary part has small absolute value.
	* math/s_ctanf.c (__ctanf): Likewise.
	* math/s_ctanh.c (__ctanh): Likewise.
	* math/s_ctanhf.c (__ctanhf): Likewise.
	* math/s_ctanhl.c (__ctanhl): Likewise.
	* math/s_ctanl.c (__ctanl): Likewise.
	* math/auto-libm-test-in: Do not allow missing underflow for ctan
	and ctanh.  Add more tests of ctan and ctanh.
  • Loading branch information
Joseph Myers committed Sep 15, 2015
1 parent 694aabe commit 0b87419
Show file tree
Hide file tree
Showing 10 changed files with 923 additions and 214 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
@@ -1,5 +1,16 @@
2015-09-15 Joseph Myers <joseph@codesourcery.com>

[BZ #18595]
* math/s_ctan.c (__ctan): Force underflow exception for results
whose real or imaginary part has small absolute value.
* math/s_ctanf.c (__ctanf): Likewise.
* math/s_ctanh.c (__ctanh): Likewise.
* math/s_ctanhf.c (__ctanhf): Likewise.
* math/s_ctanhl.c (__ctanhl): Likewise.
* math/s_ctanl.c (__ctanl): Likewise.
* math/auto-libm-test-in: Do not allow missing underflow for ctan
and ctanh. Add more tests of ctan and ctanh.

[BZ #15918]
* sysdeps/ieee754/flt-32/e_hypotf.c (__ieee754_hypotf): Simplify
handling of cases where one argument is an infinity.
Expand Down
8 changes: 4 additions & 4 deletions NEWS
Expand Up @@ -11,10 +11,10 @@ Version 2.23

2542, 2543, 2558, 2898, 14341, 14912, 15786, 15918, 16141, 16517, 16519,
16520, 16521, 16734, 16973, 16985, 17787, 17905, 18084, 18086, 18240,
18265, 18370, 18421, 18480, 18525, 18610, 18618, 18647, 18661, 18674,
18675, 18681, 18757, 18778, 18781, 18787, 18789, 18790, 18795, 18796,
18820, 18823, 18824, 18863, 18870, 18873, 18875, 18887, 18921, 18952,
18961, 18966.
18265, 18370, 18421, 18480, 18525, 18595, 18610, 18618, 18647, 18661,
18674, 18675, 18681, 18757, 18778, 18781, 18787, 18789, 18790, 18795,
18796, 18820, 18823, 18824, 18863, 18870, 18873, 18875, 18887, 18921,
18952, 18961, 18966.

* The obsolete header <regexp.h> has been removed. Programs that require
this header must be updated to use <regex.h> instead.
Expand Down
26 changes: 16 additions & 10 deletions math/auto-libm-test-in
Expand Up @@ -1245,11 +1245,14 @@ ctan 0x1.921fb6p+0 0x1p-149
ctan 0x1.921fb54442d18p+0 0x1p-1074
ctan 0x1.921fb54442d1846ap+0 0x1p-16445

# Bug 18595: underflow exception may be missing
ctan min 0 missing-underflow
ctan -min 0 missing-underflow
ctan min_subnorm 0 missing-underflow
ctan -min_subnorm 0 missing-underflow
ctan min 0
ctan -min 0
ctan min_subnorm 0
ctan -min_subnorm 0
ctan 0 min
ctan 0 -min
ctan 0 min_subnorm
ctan 0 -min_subnorm

ctanh 0 0
ctanh 0 -0
Expand Down Expand Up @@ -1285,11 +1288,14 @@ ctanh 0x1p-149 0x1.921fb6p+0
ctanh 0x1p-1074 0x1.921fb54442d18p+0
ctanh 0x1p-16445 0x1.921fb54442d1846ap+0

# Bug 18595: underflow exception may be missing
ctanh 0 min missing-underflow
ctanh 0 -min missing-underflow
ctanh 0 min_subnorm missing-underflow
ctanh 0 -min_subnorm missing-underflow
ctanh 0 min
ctanh 0 -min
ctanh 0 min_subnorm
ctanh 0 -min_subnorm
ctanh min 0
ctanh -min 0
ctanh min_subnorm 0
ctanh -min_subnorm 0

erf 0
erf -0
Expand Down
1,032 changes: 832 additions & 200 deletions math/auto-libm-test-out

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions math/s_ctan.c
Expand Up @@ -110,6 +110,16 @@ __ctan (__complex__ double x)
__real__ res = sinrx * cosrx / den;
__imag__ res = sinhix * coshix / den;
}
if (fabs (__real__ res) < DBL_MIN)
{
double force_underflow = __real__ res * __real__ res;
math_force_eval (force_underflow);
}
if (fabs (__imag__ res) < DBL_MIN)
{
double force_underflow = __imag__ res * __imag__ res;
math_force_eval (force_underflow);
}
}

return res;
Expand Down
10 changes: 10 additions & 0 deletions math/s_ctanf.c
Expand Up @@ -110,6 +110,16 @@ __ctanf (__complex__ float x)
__real__ res = sinrx * cosrx / den;
__imag__ res = sinhix * coshix / den;
}
if (fabsf (__real__ res) < FLT_MIN)
{
float force_underflow = __real__ res * __real__ res;
math_force_eval (force_underflow);
}
if (fabsf (__imag__ res) < FLT_MIN)
{
float force_underflow = __imag__ res * __imag__ res;
math_force_eval (force_underflow);
}
}

return res;
Expand Down
10 changes: 10 additions & 0 deletions math/s_ctanh.c
Expand Up @@ -110,6 +110,16 @@ __ctanh (__complex__ double x)
__real__ res = sinhrx * coshrx / den;
__imag__ res = sinix * cosix / den;
}
if (fabs (__real__ res) < DBL_MIN)
{
double force_underflow = __real__ res * __real__ res;
math_force_eval (force_underflow);
}
if (fabs (__imag__ res) < DBL_MIN)
{
double force_underflow = __imag__ res * __imag__ res;
math_force_eval (force_underflow);
}
}

return res;
Expand Down
10 changes: 10 additions & 0 deletions math/s_ctanhf.c
Expand Up @@ -110,6 +110,16 @@ __ctanhf (__complex__ float x)
__real__ res = sinhrx * coshrx / den;
__imag__ res = sinix * cosix / den;
}
if (fabsf (__real__ res) < FLT_MIN)
{
float force_underflow = __real__ res * __real__ res;
math_force_eval (force_underflow);
}
if (fabsf (__imag__ res) < FLT_MIN)
{
float force_underflow = __imag__ res * __imag__ res;
math_force_eval (force_underflow);
}
}

return res;
Expand Down
10 changes: 10 additions & 0 deletions math/s_ctanhl.c
Expand Up @@ -117,6 +117,16 @@ __ctanhl (__complex__ long double x)
__real__ res = sinhrx * coshrx / den;
__imag__ res = sinix * cosix / den;
}
if (fabsl (__real__ res) < LDBL_MIN)
{
long double force_underflow = __real__ res * __real__ res;
math_force_eval (force_underflow);
}
if (fabsl (__imag__ res) < LDBL_MIN)
{
long double force_underflow = __imag__ res * __imag__ res;
math_force_eval (force_underflow);
}
}

return res;
Expand Down
10 changes: 10 additions & 0 deletions math/s_ctanl.c
Expand Up @@ -117,6 +117,16 @@ __ctanl (__complex__ long double x)
__real__ res = sinrx * cosrx / den;
__imag__ res = sinhix * coshix / den;
}
if (fabsl (__real__ res) < LDBL_MIN)
{
long double force_underflow = __real__ res * __real__ res;
math_force_eval (force_underflow);
}
if (fabsl (__imag__ res) < LDBL_MIN)
{
long double force_underflow = __imag__ res * __imag__ res;
math_force_eval (force_underflow);
}
}

return res;
Expand Down

0 comments on commit 0b87419

Please sign in to comment.