]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/autoconf/c.m4 (AC_LANG_BOOL_COMPILE_TRY (C)): Use division by zero.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 4 Jun 2004 19:39:51 +0000 (19:39 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 4 Jun 2004 19:39:51 +0000 (19:39 +0000)
ChangeLog
lib/autoconf/c.m4

index 4174392a40e629563f5840aa9b8239ad43a08004..2c040cbf39052b7248dbdafba88e176a01187723 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2004-06-04  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * lib/autoconf/c.m4 (AC_LANG_BOOL_COMPILE_TRY (C)): Use division
+       by zero instead of array size, so that we can use any arithmetic
+       constant expression (instead of requiring an integer constant
+       expression).  This allows us to test expressions like DBL_MAX <
+       LDBL_MAX, which didn't conform to the C standard using the old
+       method.
+       (AC_C_LONG_DOUBLE): Put back in the tests for LDBL_MAX and LDBL_EPSILON,
+       now that we can do floating-point tests at compile time.
+
 2004-06-02  Paul Eggert  <eggert@cs.ucla.edu>
 
        * lib/autoconf/c.m4 (AC_C_LONG_DOUBLE): Don't check LDBL_MAX
index 2e98f154758d93de21a612130cb2301246c2e2c8..621d465ab191bd83995e480ade9f704117988690 100644 (file)
@@ -228,11 +228,14 @@ char (*f) () = $1;
 
 # AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
 # -------------------------------------------------
-# Be sure to use this array to avoid `unused' warnings, which are even
-# errors with `-W error'.
+# The C standard does not require a diagnostic when we compute 1 / 0
+# at compile-time, but we don't know of any compiler that fails to
+# diagnose this.  Diagnostics are required for some other expressions
+# (e.g., ((EXPRESSION) ? 0 : (0, 0)), INT_MAX + !!(EXPRESSION)),
+# but they don't work as well in practice.
 m4_define([AC_LANG_BOOL_COMPILE_TRY(C)],
-[AC_LANG_PROGRAM([$1], [static int test_array @<:@1 - 2 * !($2)@:>@;
-test_array @<:@0@:>@ = 0
+[AC_LANG_PROGRAM([$1], [static int v = 1 / !!($2);
+v = 0;
 ])])
 
 
@@ -965,6 +968,8 @@ AC_DEFUN([AC_C_LONG_DOUBLE],
                  + (DBL_MANT_DIG < LDBL_MANT_DIG)
                  - (LDBL_MAX_EXP < DBL_MAX_EXP)
                  - (LDBL_MANT_DIG < DBL_MANT_DIG)))
+          && (0 < ((DBL_MAX < LDBL_MAX) + (LDBL_EPSILON < DBL_EPSILON)
+                   - (LDBL_MAX < DBL_MAX) - (DBL_EPSILON < LDBL_EPSILON)))
           && (int) LDBL_EPSILON == 0
          ]])],
       ac_cv_c_long_double=yes,