[cfe-commits] [libcxx] r164266 - in /libcxx/trunk: include/complex test/numerics/complex.number/complex.transcendentals/tan.pass.cpp

Howard Hinnant hhinnant at apple.com
Wed Sep 19 16:51:48 PDT 2012


Author: hhinnant
Date: Wed Sep 19 18:51:47 2012
New Revision: 164266

URL: http://llvm.org/viewvc/llvm-project?rev=164266&view=rev
Log:
Add overflow check to tanh(complex) and reduce to finite answer.  Fixes http://llvm.org/bugs/show_bug.cgi?id=13874

Modified:
    libcxx/trunk/include/complex
    libcxx/trunk/test/numerics/complex.number/complex.transcendentals/tan.pass.cpp

Modified: libcxx/trunk/include/complex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/complex?rev=164266&r1=164265&r2=164266&view=diff
==============================================================================
--- libcxx/trunk/include/complex (original)
+++ libcxx/trunk/include/complex Wed Sep 19 18:51:47 2012
@@ -1351,7 +1351,11 @@
     _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

Modified: libcxx/trunk/test/numerics/complex.number/complex.transcendentals/tan.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/complex.number/complex.transcendentals/tan.pass.cpp?rev=164266&r1=164265&r2=164266&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/complex.number/complex.transcendentals/tan.pass.cpp (original)
+++ libcxx/trunk/test/numerics/complex.number/complex.transcendentals/tan.pass.cpp Wed Sep 19 18:51:47 2012
@@ -30,6 +30,7 @@
 test()
 {
     test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+    test(std::complex<T>(10000, -10000), std::complex<T>(0, -1));
 }
 
 void test_edges()





More information about the cfe-commits mailing list