This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[patch] std::polar requires non-negative rho
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 13 May 2015 14:32:33 +0100
- Subject: [patch] std::polar requires non-negative rho
- Authentication-results: sourceware.org; auth=none
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4383.html#2459
Voted into the WP in Lenexa.
Tested powerpc64le-linux, comitted to trunk.
commit 9bf3b9ea20334711ecdced656323f69959521a82
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed May 13 14:18:03 2015 +0100
* include/std/complex (polar): Check for negative rho (LWG 2459).
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex
index 585683c..f2a6cf9 100644
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -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>