https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128135

John David Anglin <danglin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |danglin at gcc dot gnu.org

--- Comment #5 from John David Anglin <danglin at gcc dot gnu.org> ---
On targets whose <math.h> does not define C99's math_errhandling / MATH_ERRNO
(such as hppa64-hp-hpux11.11), gcc.dg/errno-5.c (added in
r17-6261-g2abc365bf62) fails to compile at line 27 because (math_errhandling &
MATH_ERRNO) is used outside the #ifdef math_errhandling / #ifdef MATH_ERRNO
guards present earlier in main():

gcc/testsuite/gcc.dg/errno-5.c: In function 'main':
gcc/testsuite/gcc.dg/errno-5.c:27:8: error: 'math_errhandling' undeclared
(first use in this function)
gcc/testsuite/gcc.dg/errno-5.c:27:27: error: 'MATH_ERRNO' undeclared (first use
in this function)

Suggested fix:

gcc/testsuite/ChangeLog:

        PR tree-optimization/128135
        * gcc.dg/errno-5.c (main): Guard uses of math_errhandling and
        MATH_ERRNO.

--- a/gcc/testsuite/gcc.dg/errno-5.c
+++ b/gcc/testsuite/gcc.dg/errno-5.c
@@ -24,7 +24,15 @@ int main(void)
   double r = pow(1e-310, -1.0);
   if (r != HUGE_VAL)
     __builtin_abort();
+#ifdef math_errhandling
+#ifdef MATH_ERRNO
   if ((math_errhandling & MATH_ERRNO) && errno != ERANGE)
     __builtin_abort();
+#else
+  if ((math_errhandling & 1) && errno != ERANGE)
+    __builtin_abort();
+#endif
+#else
+  if (errno != ERANGE)
+    __builtin_abort();
+#endif
   return 0;
 }

Reply via email to