Jim Meyering wrote: > Paul Eggert wrote: >> On 06/15/11 08:17, Jim Meyering wrote: >> >>> + vasnprintf: avoid a warning from gcc -Wsign-compare >>> + * lib/vasnprintf.c (VASNPRINTF): Cast a known-positive quantity to >>> + size_t in order to avoid a warning from gcc -Wsign-compare. >> >> Given that the context is this: >> >> if (count >= 0) >> { >> /* Verify that snprintf() has NUL-terminated its >> result. */ >> if (count < maxlen >> && ((TCHAR_T *) (result + length)) [count] != >> '\0') >> abort (); >> >> wouldn't it be better to send the GCC maintainers a bug report? >> Since maxlen is unsigned, and since it is obvious to >> the compiler that count is nonnegative, there is no reason for >> a sign-compare warning here. > > Yes, but that takes longer... > Thanks for the prod. > I've done it: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49426
That has been marked as a duplicate of this report from 2008-12-10: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 The comments there suggest that this will not be fixed any time soon, so I re-propose the cast-adding patch. If you prefer, I'll be happy to add a FIXME comment suggesting to reexamine this case (hopefully removing the cast) in a year or two.