[binutils-gdb] gprofng format mismatch on 32-bit host

Alan Modra via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9eb711f709fb23e6ce066159d199ea8baccacee5

commit 9eb711f709fb23e6ce066159d199ea8baccacee5
Author: Alan Modra <[email protected]>
Date:   Mon Apr 6 09:32:06 2026 +0930

    gprofng format mismatch on 32-bit host
    
    On a 32-bit host without --enable-64-bit-bfd
    
    gp-gmon.cc:531:42: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘bfd_size_type’ {aka ‘unsigned int’} [-Wformat=]
    
    On a 32-bit-host with --enable-64-bit-bfd the underlying type will be
    unsigned long long.
    
            * src/gp-gmon.cc (gen_gmon_map): Use %llu to print msize, and cast.

Diff:
---
 gprofng/src/gp-gmon.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gprofng/src/gp-gmon.cc b/gprofng/src/gp-gmon.cc
index d3b4a67f51c..f8a8adb7fc9 100644
--- a/gprofng/src/gp-gmon.cc
+++ b/gprofng/src/gp-gmon.cc
@@ -528,12 +528,12 @@ gen_gmon_map (char *name)
   msize = (msize + page_size - 1) & mpage;
 
   fprintf (mapx, "<event kind=\"map\" object=\"segment\" tstamp=\"%u.%09u\" "
-	   "vaddr=\"0x%016llX\" size=\"%lu\" pagesz=\"%d\" foffset=\"%c0x%08llX\" "
+	   "vaddr=\"0x%016llX\" size=\"%llu\" pagesz=\"%d\" foffset=\"%c0x%08llX\" "
 	   "modes=\"0x%03X\" chksum=\"0x%0X\" name=\"%s\"/>\n",
 	   (unsigned) (timestamp / NANOSEC),
 	   (unsigned) (timestamp % NANOSEC),
-	   (long long unsigned) loadaddr, msize, (int) page_size,
-	   offset < 0 ? '-' : '+',
+	   (long long unsigned) loadaddr, (long long unsigned) msize,
+	   (int) page_size, offset < 0 ? '-' : '+',
 	   (long long unsigned) (offset < 0 ? -offset : offset),
 	   modeflags, check, name);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.