stubs.c (hypot, [...]): Don't divide by zero.
authorDanny Smith <dannysmith@users.sourceforge.net>
Wed, 21 May 2003 00:51:24 +0000 (00:51 +0000)
committerDanny Smith <dannysmith@gcc.gnu.org>
Wed, 21 May 2003 00:51:24 +0000 (00:51 +0000)
* libmath/stubs.c (hypot, hypotf, hypotl): Don't divide by
zero.
Update copyright year.

From-SVN: r67051

libstdc++-v3/ChangeLog
libstdc++-v3/libmath/stubs.c

index 356a299850b64b4843283313e4f7f1b6570d52b7..8ff83f7b0053b0a82d60ddae3ed140730c0c67a0 100644 (file)
@@ -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.
index 586fd6db80e579f26e6c0e9ccf5c970dd25ab37c..1968bffe7f9a110670b561aa3e13e4ed766372ca 100644 (file)
@@ -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);
 }