bug-coreutils
[Top][All Lists]
Advanced

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

bug#8732: uinttostr: comparison of unsigned expression < 0 is always fal


From: Paul Eggert
Subject: bug#8732: uinttostr: comparison of unsigned expression < 0 is always false
Date: Wed, 25 May 2011 15:21:18 -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 05/25/11 14:48, Eric Blake wrote:
> This patch silences the gcc warning even for gcc too old to honor the
> pragma, but I can't help but feel that it might be too gross (it makes
> functions like uinttostr larger in size).
> ...
> -      *--p = '-';
> +      if (ii)
> +        *--p = '-';

Yes, it's too gross.  Once we start down that path we'll have a big
job of making subtle changes to code that make it worse
and are put in only to pacify GCC.  Compilers should be our servants,
not our masters, and in this case GCC serves us better by being quiet
about a matter that it doesn't grok.

> -#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
> +#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) <= 0)

This change I don't mind so much, as any compiler that can't optimize
0 * e - 1 <= 0 is unlikely to optimize 0 * e - 1 < 0 either.  It'd
need a comment.  If this sort of thing silences all the warnings it
might be worth doing.





reply via email to

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