[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: AC_LONG_DOUBLE patch for IRIX 5.3, and for GCC 2.95.2
From: |
Paul Eggert |
Subject: |
FYI: AC_LONG_DOUBLE patch for IRIX 5.3, and for GCC 2.95.2 |
Date: |
Fri, 16 Nov 2001 12:18:52 -0800 (PST) |
> From: Oliver Kiddle <address@hidden>
> Date: Fri, 16 Nov 2001 17:26:06 +0000
>
> Hopefully that issue I mentioned with gcc 2.95.2's float.h doesn't
> apply to any compiler that lacks long double or has a small long
> double. If it does we'll have to think again.
I looked into the problem a bit more. It turns out that gcc 2.95.2
has a bug with long double on x86; LDBL_MAX is not a constant, which
violates the C standard. The bug does not occur with gcc 3.0.2.
This also exposed a bug in CVS version of AC_LANG_BOOL_COMPILE_TRY(C).
It declares an auto array, and if GCC cannot evaluate the expression
at compile-time it defers the array bounds until run-time and thus
does not report a compile-time error. To prevent this problem the
array should be static, not auto. (Also, its name shouldn't begin
with '_'.)
I installed the following patch in the Autoconf CVS; please give it a
try on IRIX 5.3 when you have the chance. (And thanks for pestering
us to get this fixed. :-)
2001-11-16 Paul Eggert <address@hidden>
This patch implements a `long double' suggestion by Oliver Kiddle.
* lib/autoconf/c.m4 (AC_LANG_BOOL_COMPILE_TRY(C)): Make the array
static, to catch errors if the value isn't known at compile-time
and the compiler supports dynamic arrays. Change its name from
`_array_' to `test_array' to avoid potential name clashes.
(AC_C_LONG_DOUBLE): Make it a compile-time test, not a run-time
test. Do not define HAVE_LONG_DOUBLE if `long double' is no
better than double. Catch a bug in GCC 2.95.2 x86.
* doc/autoconf.texi (C Compiler): Document the above.
* NEWS: Likewise.
Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.158
diff -p -u -r1.158 c.m4
--- lib/autoconf/c.m4 2001/11/12 18:46:44 1.158
+++ lib/autoconf/c.m4 2001/11/16 20:07:57
@@ -197,8 +197,8 @@ f = $1;
# Be sure to use this array to avoid `unused' warnings, which are even
# errors with `-W error'.
m4_define([AC_LANG_BOOL_COMPILE_TRY(C)],
-[AC_LANG_PROGRAM([$1], [int _array_ @<:@1 - 2 * !($2)@:>@;
-_array_ @<:@0@:>@ = 0
+[AC_LANG_PROGRAM([$1], [static int test_array @<:@1 - 2 * !($2)@:>@;
+test_array @<:@0@:>@ = 0
])])
@@ -828,25 +828,21 @@ fi
# AC_C_LONG_DOUBLE
# ----------------
AC_DEFUN([AC_C_LONG_DOUBLE],
-[AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
-[if test "$GCC" = yes; then
- ac_cv_c_long_double=yes
-else
-AC_TRY_RUN(
-[int
-main ()
-{
- /* The Stardent Vistra knows sizeof(long double), but does not
- support it. */
- long double foo = 0.0;
- /* On Ultrix 4.3 cc, long double is 4 and double is 8. */
- exit (sizeof (long double) < sizeof (double));
-}],
-ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
-fi])
+[AC_CACHE_CHECK(
+ [for working long double with more range or precision than double],
+ [ac_cv_c_long_double],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_BOOL_COMPILE_TRY(
+ [#include <float.h>
+ long double foo = 0.0;],
+ [/* Using '|' rather than '||' catches a GCC 2.95.2 x86 bug. */
+ (DBL_MAX < LDBL_MAX) | (LDBL_EPSILON < DBL_EPSILON)
+ | (DBL_MAX_EXP < LDBL_MAX_EXP) | (DBL_MANT_DIG < LDBL_MANT_DIG)])],
+ ac_cv_c_long_double=yes,
+ ac_cv_c_long_double=no)])
if test $ac_cv_c_long_double = yes; then
AC_DEFINE(HAVE_LONG_DOUBLE, 1,
- [Define to 1 if the `long double' type works.])
+ [Define to 1 if long double works and has more range or precision
than double.])
fi
])# AC_C_LONG_DOUBLE
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.562
diff -p -u -r1.562 autoconf.texi
--- doc/autoconf.texi 2001/11/12 18:48:02 1.562
+++ doc/autoconf.texi 2001/11/16 20:08:01
@@ -4763,10 +4763,9 @@ unless the C compiler predefines it.
@defmac AC_C_LONG_DOUBLE
@acindex C_LONG_DOUBLE
@cvindex HAVE_LONG_DOUBLE
-If the C compiler supports the @code{long double} type, define
address@hidden Some C compilers that do not define
address@hidden do support the @code{long double} type; some compilers
-that define @code{__STDC__} do not support @code{long double}.
+If the C compiler supports a working @code{long double} type with more
+range or precision than the @code{double} type, define
address@hidden
@end defmac
@defmac AC_C_STRINGIZE
Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.208
diff -p -u -r1.208 NEWS
--- NEWS 2001/11/13 10:42:05 1.208
+++ NEWS 2001/11/16 20:08:01
@@ -68,6 +68,8 @@
ACTION-IF-UNKNOWN arguments. All are facultative, and the default
for ACTION-IF-TRUE is to define WORDS_BIGENDIAN like AC_C_BIGENDIAN
always did.
+- AC_C_LONG_DOUBLE now succeeds only if `long double' has more range or
+ precision than `double'.
** Generic macros
- AC_C_LONG_DOUBLE is wrong on IRIX 5.3, Oliver Kiddle, 2001/11/07
- Re: AC_C_LONG_DOUBLE is wrong on IRIX 5.3, Paul Eggert, 2001/11/07
- Re: AC_C_LONG_DOUBLE is wrong on IRIX 5.3, Oliver Kiddle, 2001/11/09
- Re: AC_C_LONG_DOUBLE is wrong on IRIX 5.3, Oliver Kiddle, 2001/11/15
- Re: AC_C_LONG_DOUBLE is wrong on IRIX 5.3, Paul Eggert, 2001/11/15
- Re: AC_C_LONG_DOUBLE is wrong on IRIX 5.3, Oliver Kiddle, 2001/11/16
- Re: AC_C_LONG_DOUBLE is wrong on IRIX 5.3, Oliver Kiddle, 2001/11/16
- FYI: AC_LONG_DOUBLE patch for IRIX 5.3, and for GCC 2.95.2,
Paul Eggert <=