aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2003-05-21 00:51:24 +0000
committerDanny Smith <dannysmith@gcc.gnu.org>2003-05-21 00:51:24 +0000
commit93c858e31ac4de363f6196c909331f1141b43c05 (patch)
treea6b1c2be1ef14319f9648004696ee011b0addc18
parentc1625e69f775b74a51105b936d11aa2a0ca580fc (diff)
downloadgcc-93c858e31ac4de363f6196c909331f1141b43c05.zip
gcc-93c858e31ac4de363f6196c909331f1141b43c05.tar.gz
gcc-93c858e31ac4de363f6196c909331f1141b43c05.tar.bz2
stubs.c (hypot, [...]): Don't divide by zero.
* libmath/stubs.c (hypot, hypotf, hypotl): Don't divide by zero. Update copyright year. From-SVN: r67051
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/libmath/stubs.c8
2 files changed, 13 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 356a299..8ff83f7 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2003-05-21 Danny Smith <dannysmith@users.sourceforge.net>
+
+ * libmath/stubs.c (hypot, hypotf, hypotl): Don't divide by
+ zero.
+ Update copyright year.
+
2003-05-20 Paolo Carlini <pcarlini@unitus.it>
* testsuite/27_io/basic_filebuf/close/char/4.cc: Fix typo.
diff --git a/libstdc++-v3/libmath/stubs.c b/libstdc++-v3/libmath/stubs.c
index 586fd6d..1968bff 100644
--- a/libstdc++-v3/libmath/stubs.c
+++ b/libstdc++-v3/libmath/stubs.c
@@ -1,6 +1,6 @@
/* Stub definitions for libmath subpart of libstdc++. */
-/* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU ISO C++ Library. This library is free
software; you can redistribute it and/or modify it under the
@@ -108,6 +108,8 @@ float
hypotf(float x, float y)
{
float s = fabsf(x) + fabsf(y);
+ if (s == 0.0F)
+ return s;
x /= s; y /= s;
return s * sqrtf(x * x + y * y);
}
@@ -118,6 +120,8 @@ double
hypot(double x, double y)
{
double s = fabs(x) + fabs(y);
+ if (s == 0.0)
+ return s;
x /= s; y /= s;
return s * sqrt(x * x + y * y);
}
@@ -128,6 +132,8 @@ long double
hypotl(long double x, long double y)
{
long double s = fabsl(x) + fabsl(y);
+ if (s == 0.0L)
+ return s;
x /= s; y /= s;
return s * sqrtl(x * x + y * y);
}