bug-gnulib
[Top][All Lists]
Advanced

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

Re: proposed stdbool fixes for AIX, HP-UX, and now IRIX


From: Bruno Haible
Subject: Re: proposed stdbool fixes for AIX, HP-UX, and now IRIX
Date: Thu, 26 Jan 2006 14:35:07 +0100
User-agent: KMail/1.5

Paul Eggert wrote:
> How about this change?  It reflects what's currently installed into
> coreutils (I merged your changes).  I've tested this with GCC 2.95 and
> it works the way you like there.

Thanks,

> The basic idea is to make bool an
> enum type when using GCC, but to fall back on signed char
> otherwise.  This simplifies stdbool_.h and makes it more conservative.
> The ChangeLog entry has the most-complicated conditional I've ever
> written inside [brackets], but that complication is there precisely
> because the proposed patch removes it from the code.

Thanks, Since I don't mind about debuggability with non-gcc compilers,
I've applied your patch regarding the non-gcc compilers, with
slightly different comments.

Your patch also modifies the behaviour when gcc is used and it has _Bool
but <stdbool.h> as a whole doesn't work. We haven't seen a bug in this area,
and I remember that for several gcc versions, the problems were in the
stdbool.h file, not in the built-in type. So I propose to continue using
_Bool in that case, unlike your patch.

The ChangeLog conditional became slightly less complicated due to this.

I applied the appended patches.

Bruno

*** lib/stdbool_.h      25 Jan 2006 13:55:43 -0000      1.9
--- lib/stdbool_.h      26 Jan 2006 13:31:49 -0000      1.10
***************
*** 78,103 ****
  typedef bool _Bool;
  # endif
  #else
! # if @HAVE__BOOL@
! #  if defined __HP_cc || defined __xlc__
!     /* Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
!        the built-in _Bool type is used.  See
!          http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
!          http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
!          http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
!        Override it.  */
! #   define _Bool signed char
  enum { false = 0, true = 1 };
- #  endif
  # else
! #  if (defined __SUNPRO_C && (__SUNPRO_C < 0x550 || __STDC__ == 1)) || 
(defined __sgi && !defined __GNUC__)
!     /* With SunPRO C, avoid stupid
!          "warning: _Bool is a keyword in ISO C99".
!        With IRIX cc, avoid stupid
!          "warning(1185): enumerated type mixed with another type".  */
! #   define _Bool signed char
! enum { false = 0, true = 1 };
! #  else
  typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
  #  endif
  # endif
--- 78,106 ----
  typedef bool _Bool;
  # endif
  #else
! # if !defined __GNUC__
!    /* If @HAVE__BOOL@:
!         Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
!         the built-in _Bool type is used.  See
!           http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
!           
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
!           
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
!         Similar bugs are likely with other compilers as well; this file
!         wouldn't be used if <stdbool.h> was working.
!         So we override the _Bool type.
!       If address@hidden@:
!         Need to define _Bool ourselves. As 'signed char' or as an enum type?
!         Use of a typedef, with SunPRO C, leads to a stupid
!           "warning: _Bool is a keyword in ISO C99".
!         Use of an enum type, with IRIX cc, leads to a stupid
!           "warning(1185): enumerated type mixed with another type".
!         The only benefit of the enum type, debuggability, is not important
!         with these compilers.  So use 'signed char' and no typedef.  */
! #  define _Bool signed char
  enum { false = 0, true = 1 };
  # else
!    /* With this compiler, trust the _Bool type if the compiler has it.  */
! #  if address@hidden@
  typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
  #  endif
  # endif
*** m4/stdbool.m4       24 Jan 2006 22:05:28 -0000      1.9
--- m4/stdbool.m4       26 Jan 2006 13:32:38 -0000      1.10
***************
*** 74,80 ****
          _Bool n[m];
          char o[sizeof n == m * sizeof n[0] ? 1 : -1];
          char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
!         #if defined __xlc__
           /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
              reported by James Lemley on 2005-10-05; see
              
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
--- 74,80 ----
          _Bool n[m];
          char o[sizeof n == m * sizeof n[0] ? 1 : -1];
          char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
!         #if defined __xlc__ || defined __GNUC__
           /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
              reported by James Lemley on 2005-10-05; see
              
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
***************
*** 86,92 ****
              Let us hope that IBM fixes the xlc bug, and also adds
              support for this kind of constant expression.  In the
              meantime, this test will reject xlc, which is OK, since
!             our stdbool.h substitute should suffice.  */
           char digs[] = "0123456789";
           int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
          #endif
--- 86,95 ----
              Let us hope that IBM fixes the xlc bug, and also adds
              support for this kind of constant expression.  In the
              meantime, this test will reject xlc, which is OK, since
!             our stdbool.h substitute should suffice.  We also test
!             this with GCC, where it should work, to detect more
!             quickly whether someone messes up the test in the
!             future.  */
           char digs[] = "0123456789";
           int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
          #endif
***************
*** 98,106 ****
          _Bool *pq = &q;
        ],
        [
          /* Refer to every declared value, to avoid compiler optimizations.  */
          return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
!                 + !m + !n + !o + !p);
        ],
        [ac_cv_header_stdbool_h=yes],
        [ac_cv_header_stdbool_h=no])])
--- 101,111 ----
          _Bool *pq = &q;
        ],
        [
+         *pq |= q;
+         *pq |= ! q;
          /* Refer to every declared value, to avoid compiler optimizations.  */
          return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
!                 + !m + !n + !o + !p + !q + !pq);
        ],
        [ac_cv_header_stdbool_h=yes],
        [ac_cv_header_stdbool_h=no])])





reply via email to

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