From 5ddfb9fbf947533efc2bf7ea764c8e9f93348ab3 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 24 Jan 2006 22:05:28 +0000 Subject: [PATCH] Check against AIX and HP-UX C compiler bugs. --- m4/ChangeLog | 5 +++++ m4/stdbool.m4 | 24 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/m4/ChangeLog b/m4/ChangeLog index 5d6acdc1d..13ac8a10a 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,8 @@ +2006-01-24 Bruno Haible + + * stdbool.m4 (AC_HEADER_STDBOOL): Check for IBM and HP-UX bugs. + Patch by Paul Eggert. + 2006-01-24 Jim Meyering * openat.m4 (gl_FUNC_OPENAT): Add AC_LIBSOURCES([intprops.h]). diff --git a/m4/stdbool.m4 b/m4/stdbool.m4 index dcb579353..f37f27b97 100644 --- a/m4/stdbool.m4 +++ b/m4/stdbool.m4 @@ -1,6 +1,6 @@ # Check for stdbool.h that conforms to C99. -dnl Copyright (C) 2002-2005 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -74,6 +74,28 @@ AC_DEFUN([AC_HEADER_STDBOOL], _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 + This test is not quite right, since xlc is allowed to + reject this program, as the initializer for xlcbug is + not one of the forms that C requires support for. + However, doing the test right would require a run-time + test, and that would make cross-compilation harder. + 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 + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; ], [ /* Refer to every declared value, to avoid compiler optimizations. */ -- 2.11.0