In message <[EMAIL PROTECTED]>, Earnie Boyd writes:
>--- Steve Robbins <[EMAIL PROTECTED]> wrote:
>> Has it always been the case that `0<5' is `1'?
>
>I think I remember cases (VAX?) of 0<5 produces -1.
Dear me. Actually, BCPL's truth value is -1, so I can believe early
versions of C might behave the same way.
We can fix this by using Tom's negative array size trick here too.
Re-revised patch attached.
I'm unsure how `int a[0];' will be handled by various compilers. The
ANSI standard (3.5.4.2 first paragraph) says:
The expression delimited by [ and ] (which specifies the size of an
array) shall be an integral constant expression that has a value
greater than zero.
So an ANSI C compiler can reasonably reject it; gcc 2.95.2 happily
compiles it (arguably a gcc bug I guess - I can't see it being argued
to be a useful extension). Anyway, to sidestep this issue I double
and add one.
Cheers,
Olly
===
diff -u -r1.222 acspecific.m4
--- acspecific.m4 2000/02/10 13:14:58 1.222
+++ acspecific.m4 2000/02/22 18:46:20
@@ -2395,17 +2395,8 @@
#endif
], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
else
-AC_TRY_RUN(
-[/* volatile prevents gcc2 from optimizing the test away on sparcs. */
-#if !defined(__STDC__) || __STDC__ != 1
-# define volatile
-#endif
-int
-main()
-{
- volatile char c = 255;
- exit(c < 0);
-}], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
+AC_TRY_COMPILE(, [int a[(char)-1];],
+ ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no)
fi])
if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
AC_DEFINE(__CHAR_UNSIGNED__)
@@ -2420,16 +2411,16 @@
[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
+AC_TRY_COMPILE(,
+[/* 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));
-}],
+ /* On Ultrix 4.3 cc, long double is 4 and double is 8.
+ We use `* 2 + 1' to preserve the sign of small positive and negative
+ values, while avoiding the ambiguous `int a[0];'
+ (gcc 2.95.2 allows it; ANSI C specifies size "greater than zero") */
+ int a[((int)sizeof(long double) - (int)sizeof(double)) * 2 + 1];],
+],
ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
fi])
if test $ac_cv_c_long_double = yes; then