Joel E. Denny wrote: > On Tue, 29 Sep 2009, Jim Meyering wrote: >> I tried to bootstrap/build "master" today, without >> success, so switched to branch-2.5. There, ./bootstrap >> succeeded, but the build failed with two like this: >> >> Sbitset.c: In function 'Sbitset__fprint': >> Sbitset.c:75: error: format '%d' expects type 'int', but argument 3 >> has type 'Sbitset__Index > > Thanks for the report. I'm not seeing those failures with either gcc > 4.2.4 or 4.3.4. Which gcc are you using?
Hi Joel, I'm using the stock gcc on an up-to-date Fedora 11 system: gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC) >> With the change below, the build and "make check" succeeded. ... >> - fprintf (file, " %d", i); >> + fprintf (file, " %d", (int) i); >> } >> fprintf (file, " }"); >> } > > Because Sbitset__index is a size_t, wouldn't the following patch be > better? > >>From 47eced3099712180364f4e01b839242027d9a9d8 Mon Sep 17 00:00:00 2001 > From: Joel E. Denny <[email protected]> > Date: Tue, 29 Sep 2009 06:54:38 -0400 > Subject: [PATCH] Use the correct conversion specifier for size_t. > > Reported by Jim Meyering. > * src/Sbitset.h (SBITSET__INDEX__CONVERSION_SPEC): New, "zu" > because Sbitset__Index is size_t. > * src/Sbitset.c (Sbitset__fprint): Use it instead of %d. ... > - fprintf (file, " %d", i); > + fprintf (file, " %" SBITSET__INDEX__CONVERSION_SPEC, i); ... > +#define SBITSET__INDEX__CONVERSION_SPEC "zu" I didn't know (and didn't dig) if it could be negative, presumed that the author chose %d for a good reason, and took the quick and dirty add-cast approach. I'm glad there was a better say.
