This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] libstdc++/20352
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Cc: John David Anglin <dave at hiauly1 dot hia dot nrc dot ca>
- Date: Mon, 14 Mar 2005 21:06:13 +0100
- Subject: [Patch] libstdc++/20352
Hi,
this PR points out that non-c99 platforms don't guarantee that
atan2(0, +0) == 0. The proposed solution leads also to improved
consistency in the behavior of the various cplx pow overloads
for null base and exponent. To wit, on c99 platforms (exploiting
the builtins) all the overloads the same value, typically (f.i.,
for glibc) (nan, nan); on non-c99 platforms, that is using the
open coded implementation, (0, 0), consistently.
The price is an additional conditional in the involved overload
for non-c99 platforms, but hopefully, this case will become
less and less frequent in the future.
Tested x86-linux, also undef-ing _GLIBCXX_USE_C99_COMPLEX.
I will wait until tomorrow, in case of issues.
Paolo.
P.S. There is a minor risk that, a platform that we consider
_GLIBCXX_USE_C99_COMPLEX may have a broken atan2, that is not
conforming to F.9.1.4. In that case we can only improve the
autoconf tests for _GLIBCXX_USE_C99_COMPLEX. Seems a largely
independent issue, however.
/////////////////
2005-03-15 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/20352
* include/std/std_complex.h (pow(const complex<_Tp>&,
const _Tp&)): On non-c99 platforms, don't try to compute
log of complex zero.
diff -urN libstdc++-v3-orig/include/std/std_complex.h libstdc++-v3/include/std/std_complex.h
--- libstdc++-v3-orig/include/std/std_complex.h 2005-03-07 23:22:35.000000000 +0100
+++ libstdc++-v3/include/std/std_complex.h 2005-03-14 20:23:41.000000000 +0100
@@ -944,6 +944,10 @@
complex<_Tp>
pow(const complex<_Tp>& __x, const _Tp& __y)
{
+#ifndef _GLIBCXX_USE_C99_COMPLEX
+ if (__x == _Tp())
+ return _Tp();
+#endif
if (__x.imag() == _Tp() && __x.real() > _Tp())
return pow(__x.real(), __y);