stdbool test: Avoid a gcc warning.
authorBruno Haible <bruno@clisp.org>
Sun, 19 Dec 2010 22:51:54 +0000 (23:51 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 19 Dec 2010 22:51:54 +0000 (23:51 +0100)
* tests/test-stdbool.c (main): Fail if e1 is false.
Reported by Jim Meyering.

ChangeLog
tests/test-stdbool.c

index 357f06f..3d35faa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-12-19  Bruno Haible  <bruno@clisp.org>
+
+       stdbool test: Avoid a gcc warning.
+       * tests/test-stdbool.c (main): Fail if e1 is false.
+       Reported by Jim Meyering.
+
 2010-12-19  Jim Meyering  <meyering@redhat.com>
 
        setenv: restore to working order
index bb8d6f3..d47f1c6 100644 (file)
@@ -90,10 +90,16 @@ _Bool *pq = &q;
 int
 main ()
 {
+  int error = 0;
+
 #if HAVE_STDBOOL_H || defined __GNUC__ /* See above.  */
 # ifdef ADDRESS_CHECK_OKAY /* Avoid gcc warning.  */
   /* A cast from a variable's address to bool is valid in expressions.  */
-  bool e1 = &s;
+  {
+    bool e1 = &s;
+    if (!e1)
+      error = 1;
+  }
 # endif
 #endif
 
@@ -102,6 +108,11 @@ main ()
      http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
      This is a runtime test, since a corresponding compile-time
      test would rely on initializer extensions.  */
-  char digs[] = "0123456789";
-  return &(digs + 5)[-2 + (bool) 1] != &digs[4];
+  {
+    char digs[] = "0123456789";
+    if (&(digs + 5)[-2 + (bool) 1] != &digs[4])
+      error = 1;
+  }
+
+  return error;
 }