Fix -Wconstant-logical-operand error in tst-printf-format-skeleton.c

Joseph Myers josmyers@redhat.com
Wed Jun 10 13:39:32 GMT 2026


Building the glibc testsuite with GCC mainline fails with:

In file included from tst-printf-format-skeleton-double.c:33,
                 from tst-printf-format-p-double.c:20:
tst-printf-format-skeleton.c: In function 'do_test':
tst-printf-format-skeleton.c:308:12: error: use of logical '&&' with constant operand '53' [-Werror=constant-logical-operand]
  308 |   if (PREC && printf ("prec:%i\n", PREC) < 0)
      |            ^~
tst-printf-format-skeleton.c:308:12: note: use '&' for bitwise operation
  308 |   if (PREC && printf ("prec:%i\n", PREC) < 0)
      |            ^~
      |            &
cc1: all warnings being treated as errors

Fix this using an explicit "!= 0".  Tested with build-many-glibcs.py
for aarch64-linux-gnu.

diff --git a/stdio-common/tst-printf-format-skeleton.c b/stdio-common/tst-printf-format-skeleton.c
index 3ed7668ce7..000d8fa50d 100644
--- a/stdio-common/tst-printf-format-skeleton.c
+++ b/stdio-common/tst-printf-format-skeleton.c
@@ -305,7 +305,7 @@ do_test (int argc, char *argv[])
 
   mtrace ();
 
-  if (PREC && printf ("prec:%i\n", PREC) < 0)
+  if (PREC != 0 && printf ("prec:%i\n", PREC) < 0)
     {
       perror ("printf");
       return EXIT_FAILURE;

-- 
Joseph S. Myers
josmyers@redhat.com



More information about the Libc-alpha mailing list