bug-gnulib
[Top][All Lists]
Advanced

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

Re: warning: comparison is always false due to limited range of data typ


From: Jim Meyering
Subject: Re: warning: comparison is always false due to limited range of data type
Date: Wed, 31 Aug 2005 09:51:11 +0200

Jim Meyering <address@hidden> wrote:
> Paul Eggert <address@hidden> wrote:
>> It will take a while for this [gcc] fix to propagate, though.  In the

Is there a patch yet to make gcc suppress that warning?

FYI, here is the warning again
[line 586 referred to the test in the expansion of xalloc_oversized]:

> quotearg.c: In function `quotearg_n_options':
> quotearg.c:586: warning: comparison is always false due to limited range of
> data type

In the meantime, I've just checked in this change in coreutils/lib:

2005-08-31  Jim Meyering  <address@hidden>

        * quotearg.c (quotearg_n_options): Change code to be suboptimal, in
        order to avoid an unsuppressible warning from gcc on 64-bit systems.

Index: lib/quotearg.c
===================================================================
RCS file: /fetish/cu/lib/quotearg.c,v
retrieving revision 1.45
diff -u -p -r1.45 quotearg.c
--- lib/quotearg.c      14 May 2005 07:58:07 -0000      1.45
+++ lib/quotearg.c      31 Aug 2005 07:27:32 -0000
@@ -581,7 +581,12 @@ quotearg_n_options (int n, char const *a
 
   if (nslots <= n0)
     {
-      unsigned int n1 = n0 + 1;
+      /* FIXME: technically, the type of n1 should be `unsigned int',
+        but that evokes an unsuppressible warning from gcc-4.0.1 and
+        older.  If gcc ever provides an option to suppress that warning,
+        revert to the original type, so that the test in xalloc_oversized
+        is once again performed only at compile time.  */
+      size_t n1 = n0 + 1;
 
       if (xalloc_oversized (n1, sizeof *slotvec))
        xalloc_die ();




reply via email to

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