* include/std/complex (polar): Check for negative rho (LWG 2459).
authorJonathan Wakely <jwakely@redhat.com>
Wed, 13 May 2015 13:32:31 +0000 (14:32 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 13 May 2015 13:32:31 +0000 (14:32 +0100)
From-SVN: r223159

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/complex

index a22a56524f88c8369d5dfe969f931690db1dfe0f..af4d5be54c6c2cba5648b81be42d7f5e1fca3caf 100644 (file)
@@ -1,5 +1,7 @@
 2015-05-13  Jonathan Wakely  <jwakely@redhat.com>
 
+       * include/std/complex (polar): Check for negative rho (LWG 2459).
+
        * include/experimental/tuple (apply): Handle pointers to member (LWG
        2418).
        * include/std/functional (_Mem_fn_base): Make constructors constexpr.
index 585683c6f93ad27e6612f17899ed58a4325e5ffc..f2a6cf93487d9380f995db2774e43145fa3b30bc 100644 (file)
@@ -667,7 +667,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     inline complex<_Tp>
     polar(const _Tp& __rho, const _Tp& __theta)
-    { return complex<_Tp>(__rho * cos(__theta), __rho * sin(__theta)); }
+    {
+      _GLIBCXX_DEBUG_ASSERT( __rho >= 0 );
+      return complex<_Tp>(__rho * cos(__theta), __rho * sin(__theta));
+    }
 
   template<typename _Tp>
     inline complex<_Tp>