bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] stdbool_.h bug breaks coreutils CVS sort on Alpha GCC 2


From: Bruno Haible
Subject: Re: [Bug-gnulib] stdbool_.h bug breaks coreutils CVS sort on Alpha GCC 2.95.4
Date: Tue, 5 Aug 2003 21:39:37 +0200
User-agent: KMail/1.5

Paul Eggert wrote:
> Here's a simple program that illustrates the bug in stdbool_.h.
> It should exit with status 0, but with the gnulib stdbool_.h
> it exits with status 1 (even on a 32-bit platform).
> 
>         #include <stdbool.h>
>         bool False = 0;
>         int main (void)
>         {
>           return 0 < -1 - False;
>         }

OK, it took me some time to find the paragraph of ISO C 99 that
says that _Bool must promote to 'int'. But now I agree with you.

> I've heard no other comment so I
> installed it into gnulib.

And I've extended your comments in it with references to the standard.

> One other problem with stdbool_.h was noted by Nelson H. F. Beebe
> to bug-coreutils yesterday:
>
> Sun Solaris 2.8 (SPARC), Sun Solaris 2.9 (SPARC and Intel x86)
> c89 -DHAVE_CONFIG_H -I. -I. -I..  -I.. -I. -I../lib -I../lib
> -I/usr/local/include  -xO5 -dalign -xlibmil -xcg92 -xsafe=mem -c `test -f
> 'date.c' || echo './'`date.c "../lib/stdbool.h", line 39: warning: _Bool is
> a keyword in ISO C99

What a stupid compiler! It doesn't define _Bool as a type AND doesn't let
people define it themselves.

> --- old/stdbool_.h    Sun Aug  3 00:09:12 2003
> +++ new/stdbool_.h    Sun Aug  3 00:17:40 2003
> @@ -32,11 +32,13 @@
>  /* For the sake of symbolic names in gdb, define true and false as
>     enum constants.  However, do not define _Bool as the enum type,
>     since the enum type might be compatible with unsigned int, whereas
> -   _Bool must promote to int.  */
> +   _Bool must promote to int.  Also, make _Bool a macro rather than a
> +   typedef, to suppress warnings by the Sun Forte Developer 7 C
> +   compiler that _Bool is a keyword in ISO C99.  */
>  #ifndef __cplusplus
>  # if address@hidden@
>  enum { false = 0, true = 1 };
> -typedef signed char _Bool;
> +#  define _Bool signed char
>  # endif
>  #else
>  typedef bool _Bool;

I object against this patch because a program is allowed to do

    #include <stdbool.h>
    #undef _Bool
    bool x = true;

and your patch breaks it.

If you really want to care about warnings from this particular non-free
compiler, I'd prefer a #if conditional, using an autoconf test. Just like
I had to make this @HAVE__BOOL@ test for the sake of the OSF/1 cc
compilers.

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]