diff options
| author | Howard Hinnant <hhinnant@apple.com> | 2012-09-19 23:51:47 +0000 |
|---|---|---|
| committer | Howard Hinnant <hhinnant@apple.com> | 2012-09-19 23:51:47 +0000 |
| commit | c43826f00309dbafb9f4a106d8e0369c7e8199c7 (patch) | |
| tree | 18438200280b34a92062b46a3bb2662d6268a597 /libcxx/include/complex | |
| parent | 38bfa0c529d788e048de0e6b00d5a77717245774 (diff) | |
| download | bcm5719-llvm-c43826f00309dbafb9f4a106d8e0369c7e8199c7.tar.gz bcm5719-llvm-c43826f00309dbafb9f4a106d8e0369c7e8199c7.zip | |
Add overflow check to tanh(complex) and reduce to finite answer. Fixes http://llvm.org/bugs/show_bug.cgi?id=13874
llvm-svn: 164266
Diffstat (limited to 'libcxx/include/complex')
| -rw-r--r-- | libcxx/include/complex | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libcxx/include/complex b/libcxx/include/complex index 54dbc25880e..6f8815298ca 100644 --- a/libcxx/include/complex +++ b/libcxx/include/complex @@ -1351,7 +1351,11 @@ tanh(const complex<_Tp>& __x) _Tp __2r(_Tp(2) * __x.real()); _Tp __2i(_Tp(2) * __x.imag()); _Tp __d(cosh(__2r) + cos(__2i)); - return complex<_Tp>(sinh(__2r)/__d, sin(__2i)/__d); + _Tp __2rsh(sinh(__2r)); + if (isinf(__2rsh) && isinf(__d)) + return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1), + __2i > _Tp(0) ? _Tp(0) : _Tp(-0.)); + return complex<_Tp>(__2rsh/__d, sin(__2i)/__d); } // asin |

