bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] vasnprintf: avoid a warning from gcc -Wsign-compare


From: Paul Eggert
Subject: Re: [PATCH] vasnprintf: avoid a warning from gcc -Wsign-compare
Date: Wed, 15 Jun 2011 09:47:36 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Thunderbird/3.1.10

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]