PATCH: HUGE_VAL should be Infinity: hugeval.c PATCH

John David Anglin dave@hiauly1.hia.nrc.ca
Tue Oct 17 16:06:00 GMT 2000


>   In message < 200010170458.AAA23638@hiauly1.hia.nrc.ca >you write:
>   > Having thought a little more about this, I believe the change is wrong as i
>   > will make the define in math.h inconsistent with the system's existing math
>   > library.  Thus, the patch should not be applied.
> Excellent point.
> 
> I guess the "fix" is to upgrade to hpux11 where this situation is handled
> more gracefully.  FWIW, I do most of my hpux work on hpux11 now.

Here is a hack to the hugeval.c test for review.  It should now "work"
on some non IEEE systems.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2000-10-17  J. David Anglin  <dave@hiauly1.hia.nrc.ca>

	* hugeval.c: Revise so it doesn't fail on all non IEEE754 systems.

--- gcc.c-torture/execute/ieee/hugeval.c.orig	Fri Jul 21 22:46:24 2000
+++ gcc.c-torture/execute/ieee/hugeval.c	Tue Oct 17 18:45:16 2000
@@ -3,24 +3,48 @@
 static const double zero =  0.0;
 static const double pone =  1.0;
 static const double none = -1.0;
+/* Exclude systems that don't support infinity. */
+#if !defined(__vax__)
 static const double pinf =  1.0 / 0.0;
 static const double ninf = -1.0 / 0.0;
+#endif
+static double phuge, nhuge;
 
 int
 main ()
 {
+#if !defined(__vax__)
   if (pinf != pone/zero)
     abort ();
 
   if (ninf != none/zero)
     abort ();
+#endif
 
 #ifdef HUGE_VAL
-  if (HUGE_VAL != pinf)
-    abort ();
+  /* Generate positive and negative huge values and compare to +Infinity
+   * and -Infinity.  With luck, this will identify machines with an
+   * IEEE754 compatible math library. */
+  for (phuge = exp (1.0e+30); phuge < HUGE_VAL; phuge = exp (phuge));
+  nhuge = log (zero);
+#if !defined(__vax__)
+  if ((phuge == pinf) && (nhuge == ninf))
+    {
+      if (HUGE_VAL != pinf)
+        abort ();
 
-  if (-HUGE_VAL != ninf)
-    abort ();
+      if (-HUGE_VAL != ninf)
+        abort ();
+    }
+  else
+#endif
+    {
+      if (HUGE_VAL != phuge)
+        abort ();
+
+      if (-HUGE_VAL != nhuge)
+        abort ();
+    }
 #endif
 
   exit (0);


More information about the Gcc-patches mailing list