public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* chew.c printf of intptr_t
@ 2023-02-28  0:37 Alan Modra
  2023-02-28 20:24 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Modra @ 2023-02-28  0:37 UTC (permalink / raw)
  To: binutils; +Cc: Tom Tromey

Seen when building binutils with gcc -m32 on x86_64-linux.
chew.c: In function ‘print’:
chew.c:1434:59: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘intptr_t’ {aka ‘int’} [-Wformat=]
 1434 |     fprintf (stderr, "print: illegal print destination `%ld'\n", *isp);
      |                                                         ~~^      ~~~~
      |                                                           |      |
      |                                                           |      intptr_t {aka int}
      |                                                           long int
      |                                                         %d

	* chew.c: Include inttypes.h.
	(print): Use PRIdPTR for *isp.

diff --git a/bfd/doc/chew.c b/bfd/doc/chew.c
index e8478969d64..5257bf42361 100644
--- a/bfd/doc/chew.c
+++ b/bfd/doc/chew.c
@@ -91,6 +91,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
+#include <inttypes.h>
 
 #define DEF_SIZE 5000
 #define STACK 50
@@ -1431,7 +1432,7 @@ print (void)
   else if (*isp == 2)
     write_buffer (tos, stderr);
   else
-    fprintf (stderr, "print: illegal print destination `%ld'\n", *isp);
+    fprintf (stderr, "print: illegal print destination `%" PRIdPTR "'\n", *isp);
   isp--;
   tos--;
   icheck_range ();

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: chew.c printf of intptr_t
  2023-02-28  0:37 chew.c printf of intptr_t Alan Modra
@ 2023-02-28 20:24 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-02-28 20:24 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils, Tom Tromey

>>>>> "Alan" == Alan Modra <amodra@gmail.com> writes:

Alan> Seen when building binutils with gcc -m32 on x86_64-linux.
[...]

Thank you for the fix.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-28 20:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28  0:37 chew.c printf of intptr_t Alan Modra
2023-02-28 20:24 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).