bug-gnulib
[Top][All Lists]
Advanced

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

Re: new stdbool test provokes warning


From: Bruno Haible
Subject: Re: new stdbool test provokes warning
Date: Sun, 19 Dec 2010 23:57:27 +0100
User-agent: KMail/1.9.9

Hi Jim,

> The new stdbool test causes this warning/failure in coreutils:
> 
>     cc1: warnings being treated as errors
>     test-stdbool.c: In function 'main':
>     test-stdbool.c:98:9: error: unused variable 'e1' [-Wunused-variable]
>     make[8]: *** [test-stdbool.o] Error 1

I nearly expected this, given the comments at the top of the file...

> One way to avoid those is to add an
> 
>   (void) e1;
> 
> statement after each (there's another, above),
> but that might not be enough for some compilers.

I prefer this one. Pushed:


2010-12-19  Bruno Haible  <address@hidden>

        stdbool test: Avoid a gcc warning.
        * tests/test-stdbool.c (main): Fail if e1 is false.
        Reported by Jim Meyering.

--- tests/test-stdbool.c.orig   Sun Dec 19 23:47:03 2010
+++ tests/test-stdbool.c        Sun Dec 19 23:46:53 2010
@@ -90,10 +90,16 @@
 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 @@
      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;
 }



reply via email to

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